Rewarded Video
Before start loading Admob you should load Bidmachine ad and save it to store
import BidMachine
import BidMachineAdMobAdapter
func before() throws {
let configuration = try BidMachineSdk.shared.requestConfiguration(.rewardedVideo)
BidMachineSdk.shared.rewarded(configuration) { [weak self] rewarded, error in
AdMobAdapter.store(rewarded)
self?.after()
}
}
@import BidMachine;
@import BidMachineApiCore;
@import BidMachineAdMobAdapter;
- (void)before {
__weak typeof(self) weakSelf = self;
[BidMachineSdk.shared rewarded:nil :^(BidMachineRewarded *ad, NSError *error) {
[BDMAdMobAdapter store:ad];
[weakSelf after];
}];
}
Then you can create an admob object and load it
func after() {
GADRewardedAd.load(
withAdUnitID: "unit id",
request: GADRequest(),
completionHandler: { [weak self] rewarded, error in
if let error = error {
print("Failed to load rewarded ad with error: \(error.localizedDescription)")
return
}
self?.rewarded = rewarded
self?.rewarded?.fullScreenContentDelegate = self
}
)
}
- (void)after {
GADRequest *request = [GADRequest request];
[GADRewardedAd loadWithAdUnitID:@UNIT_ID request:request completionHandler:^(GADRewardedAd * _Nullable rewardedAd, NSError * _Nullable error) {
if (error) {
// fail load
} else {
self.rewarded = rewardedAd;
self.rewarded.fullScreenContentDelegate = self;
}
}];
}
Updated about 1 year ago