Native
First you need to create a request and execute it
self.request = [BDMNativeAdRequest new];
[self.request performWithDelegate:self];
After polling, you need to save the bid request ([BDMRequestStorage.shared saveRequest:request];)
#pragma mark - BDMRequestDelegate
- (void)request:(BDMRequest *)request completeWithInfo:(BDMAuctionInfo *)info {
// After request complete loading application can lost strong ref on it
// BidMachineFetcher will capture request by itself
self.request = nil;
// Save request for bid
[BDMRequestStorage.shared saveRequest:request];
// Here we define which Admob ad should be loaded
[self makeRequest];
}
Then you can create an Admob object and load it
- (void)makeRequest {
GADRequest *request = [GADRequest request];
[self.nativeLoader loadRequest:request];
}
- (GADAdLoader *)nativeLoader {
if (!_nativeLoader) {
_nativeLoader = [[GADAdLoader alloc] initWithAdUnitID:@UNIT_ID
rootViewController:self
adTypes:@[kGADAdLoaderAdTypeNative]
options:@[self.viewOptions, self.videoOptions, self.mediaOptions]];
_nativeLoader.delegate = self;
}
return _nativeLoader;
}
- (GADAdLoaderOptions *)videoOptions {
GADVideoOptions *options = GADVideoOptions.new;
options.startMuted = YES;
return options;
}
- (GADAdLoaderOptions *)mediaOptions {
GADNativeAdMediaAdLoaderOptions *options = GADNativeAdMediaAdLoaderOptions.new;
options.mediaAspectRatio = GADMediaAspectRatioLandscape;
return options;
}
- (GADAdLoaderOptions *)viewOptions {
GADNativeAdViewAdOptions *options = GADNativeAdViewAdOptions.new;
options.preferredAdChoicesPosition = GADAdChoicesPositionTopRightCorner;
return options;
}
Updated almost 2 years ago