Google 官方 的 教學 怪怪的 不work
https://developers.google.com/admob/ios/interstitial?hl=zh-tw
以下目的為加入插頁式廣告,廣告在該頁面載入時會顯示,關閉後會啟動計時器,在30秒後再自動開啟
// CSPViewController.h @import GoogleMobileAds; @interface CSPViewController : UIViewController @end // CSPViewController.m @interface CSPViewController () @property(nonatomic, strong) GADInterstitial *interstitial; @end @implementation CSPViewController{ NSTimer *timer; } - (void)viewDidLoad{ // ... // 加入插入式廣告 self.interstitial = [self createAndLoadInterstitial]; } - (GADInterstitial *)createAndLoadInterstitial { GADInterstitial *interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-6497987983526708/719163474"]; interstitial.delegate = self; [interstitial loadRequest:[GADRequest request]]; return interstitial; } - (void)interstitialDidReceiveAd:(GADInterstitial *)ad { [self.interstitial presentFromRootViewController:self]; } - (void)interstitialDidDismissScreen:(GADInterstitial *)interstitial { timer = [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(updateInterstitial) userInfo:nil repeats:NO]; } - (void) updateInterstitial{ self.interstitial = [self createAndLoadInterstitial]; }
留言
張貼留言