MREC
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(.banner300x250)
BidMachineSdk.shared.banner(configuration) { [weak self] banner, error in
AdMobAdapter.store(banner)
self?.after()
}
}
@import BidMachine;
@import BidMachineApiCore;
@import BidMachineAdMobAdapter;
- (void)before {
__weak typeof(self) weakSelf = self;
id<BidMachineRequestConfigurationProtocol> config = [BidMachineSdk.shared requestConfiguration:BidMachinePlacementFormatBanner300x250 error:nil];
[BidMachineSdk.shared banner:config :^(BidMachineBanner *ad, NSError *error) {
[BDMAdMobAdapter store:ad];
[weakSelf after];
}];
}
Then you can create an Admob object and load it
func after() {
self.bannerView = GADBannerView(adSize: GADAdSizeMediumRectangle)
self.bannerView.delegate = self
self.bannerView.adUnitID = "unit id"
self.bannerView.rootViewController = self
self.bannerView.load(GADRequest())
}
- (void)after {
self.bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; // kGADAdSizeMediumRectangle
self.bannerView.delegate = self;
self.bannerView.adUnitID = @UNIT_ID;
self.bannerView.rootViewController = self;
self.bannerView.translatesAutoresizingMaskIntoConstraints = YES;
self.bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
GADRequest *request = [GADRequest request];
[self.bannerView loadRequest:request];
}
Updated 12 months ago