Interstitial
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(.interstitial)
BidMachineSdk.shared.interstitial(configuration) { [weak self] interstitial, error in
AdMobAdapter.store(interstitial)
self?.after()
}
}
@import BidMachine;
@import BidMachineApiCore;
@import BidMachineAdMobAdapter;
- (void)before {
__weak typeof(self) weakSelf = self;
[BidMachineSdk.shared interstitial:nil :^(BidMachineInterstitial *ad, NSError *error) {
[BDMAdMobAdapter store:ad];
[weakSelf after];
}];
}
Then you can create an admob object and load it
func after() {
GADInterstitialAd.load(
withAdUnitID: "unit id",
request: GADRequest(),
completionHandler: { [weak self] interstitial, error in
if let error = error {
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
return
}
self?.interstitial = interstitial
self?.interstitial?.fullScreenContentDelegate = self
}
)
}
- (void)after {
GADRequest *request = [GADRequest request];
[GADInterstitialAd loadWithAdUnitID:@UNIT_ID request:request completionHandler:^(GADInterstitialAd * _Nullable interstitialAd, NSError * _Nullable error) {
if (error) {
// fail load
} else {
self.interstitial = interstitialAd;
self.interstitial.fullScreenContentDelegate = self;
}
}];
}
Updated 12 months ago
What’s Next