// 加载开屏广告
[KLNSplashAd loadWithRequest:req completionHandler:^(KLNSplashAd *splashAd, NSError *error) {
if (error) {
KLNDemoLog(@"加载开屏广告失败:%@", error);
return;
}
KLNDemoLog(@"开屏广告Ready");
self.splashAd = splashAd;
[self updateButtonState];
// 1、获取广告价格
NSInteger price = [splashAd eCPM];
KLNDemoLog(@"广告价格:%d",price);
// 2、广告比价
// 3、竞价结果调用
[self reportBidding:splashAd];
// 4、展示广告
dispatch_async(dispatch_get_main_queue(), ^{
if (self.splashAutoShowSelectButton.isSelected) {
if ([splashAd canPresentFromRootViewController:self error:nil]) {
[splashAd presentFromRootViewController:self];
}
[self updateButtonState];
}
});
}];
- (void)reportBidding:(KLNSplashAd *)ad{
KLNAdBiddingResult result = KLNDemoBiddingManager.manager.biddingResult;
if (result == KLNAdBiddingResultWin) {
int price = KLNDemoBiddingManager.manager.price;
[ad sendWinNotificationWithPrice:price];
}else if(result == KLNAdBiddingResultLoss){
int price = KLNDemoBiddingManager.manager.price;
KLNAdBiddingLossReason reason = KLNDemoBiddingManager.manager.biddingLossReason;
NSString *adnID = KLNDemoBiddingManager.manager.adnID;
[ad sendLossNotificationWithWinnerPrice:price lossReason:reason winnerAdnID:adnID];
}
}