GADInterstitial* _myInterstitial; //生命一个全局GAD对象
在程序启动时初始化一下方便以后使用
_myInterstitial = [[GADInterstitial alloc]init];
_myInterstitial.delegate = self;
_myInterstitial.adUnitID = @"广告ID";
实现以下代理方法,此时接收到添加广告消息显示
- (void)interstitialDidReceiveAd:(GADInterstitial *)ad
{
[_myInterstitial presentFromRootViewController: viewController];
}
接受广告消息失败后回调方法
- (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error
{
NSLog(@"error: %@",error);
}
关闭广告回调方法,关闭之后再初始化,方便下一次调用显示
- (void)interstitialDidDismissScreen:(GADInterstitial *)ad
{
_myInterstitial = [[GADInterstitial alloc]init];
_myInterstitial.delegate = self;
_myInterstitial.adUnitID = @"广告ID";
}
//触发显示广告方法
[_myInterstitial loadRequest:[GADRequest request]];
我只是写了一部分,只是想自己做一个笔记,如果有什么不对不妥感谢大家指正,希望能对大家有所帮助~~