檢視 IOS SDK Developer Guide 的原始碼
←
IOS SDK Developer Guide
跳至導覽
跳至搜尋
由於下列原因,您沒有權限進行編輯此頁面的動作:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
== iOS SDK Developer Guide == *SDK相容性 :目前SDK相容於iOS 4.3以上的版本 :*Valid Architectures為armv7及armv7s :*Base SDK為iOS 6.1 :*Compiler為Apple LLVM compiler 4.2 :*Xcode為4.6.2版本 *整合至應用程式 :#將libTWMTAMediaView.a (函式檔) 加入iOS Project中 :#將TWMTAMediaView.h (標頭檔) 加入iOS Project中 :#將TWMTAMediaInterstitialView.h (標頭檔) 加入iOS Project中 :#將CloseButton.png (圖檔) 加入iOS Project中 :#確認原本iOS project是否有將CoreTelephony.framework加入, 若無則加入此framework :#確認原本iOS project是否有將CoreLocation.framework加入, 若無則加入此framework :#確認原本iOS project是否有將SystemConfiguration.framework加入, 若無則加入此framework :#在Targets -> Build Setting裡面設定Other Linker Flags為-ObjC(參考http://developer.apple.com/library/mac/#qa/qa1490/_index.html) :[[檔案:5.png]] :[[檔案:6.png]] *展示Banner廣告 :*Include Header #import "TWMTAMediaView.h" :*建立廣告版位 _adView = [[TWMTAMediaView alloc] initWithFrame:frame slotId:@"xxxxxxxxxx" developerID:@"my_id" gpsEnabled:YES testMode:NO]; :::gpsEnabled : GPS開關,可設定是否啟用GPS :::testMode : 測試開關,可設定是否為測試模式,測試模式中會在console顯示詳細log :*Implement Delegate :我們提供四個Callback方法,可以讓你在Banner廣告載入過程接收到對應的通知 @interface TWMTAMediaViewController () <TWMTAMediaViewDelegate> _adView.delegate = self; - (void)viewWillLoadAd:(TWMTAMediaView *)view { NSLog(@"%@ viewWillLoadAd", view); } - (void)viewDidLoadAd:(TWMTAMediaView *)view { NSLog(@"%@ viewDidLoadAd", view); } - (void)view:(TWMTAMediaView *)view didFailToReceiveAdWithError:(NSError *)error { NSLog(@"%@ didFailToReceiveAdWithError:%@", view, error.description); } - (BOOL)viewActionShouldBegin:(TWMTAMediaView *)view willLeaveApplication:(BOOL)willLeave { NSLog(@"%@ willLeaveApplication:%i", view, willLeave); return YES; } :*接收廣告 [_adView receiveAd]; :*dealloc _adView.delegate = nil; [_adView release]; _adView = nil; :::建議在廣告呈現的ViewController要release之前,先將_adView.delegate設為nil *展示Interstitial廣告 :*Include Header #import "TWMTAMediaInterstitialView.h" :*建立廣告版位 CGRect frame = CGRectMake(0, 0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height); _interstitialView = [[TWMTAMediaInterstitialView alloc] initWithFrame:frame slotId:@"xxxxxxxxxx" developerID:@"my_id" gpsEnabled:YES testMode:NO]; :::gpsEnabled : GPS開關,可設定是否啟用GPS :::testMode : 測試開關,可設定是否為測試模式,測試模式中會在console顯示詳細log :*Implement Delegate @interface TWMTAMediaViewController () <TWMTAMediaInterstitialViewDelegate> _interstitialView.delegate = self; - (void)interstitialViewWillLoadAd:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewWillLoadAd", view); } - (void)interstitialViewDidLoadAd:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewDidLoadAd", view); [_interstitialView showAd:self.view]; } - (void)interstitialView:(TWMTAMediaInterstitialView *)view didFailToReceiveAdWithError:(NSError *)error { NSLog(@"%@ interstitialViewdidFailToReceiveAdWithError:%@", view, error.description); } - (BOOL)interstitialViewActionShouldBegin:(TWMTAMediaInterstitialView *)view willLeaveApplication:(BOOL)willLeave { NSLog(@"%@ interstitialViewwillLeaveApplication:%i", view, willLeave); return YES; } - (void)interstitialViewWillDisappear:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewWillDisappear", view); } - (void)interstitialViewDidDisappear:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewDidDisappear", view); } :*接收廣告 [_interstitialView receiveAd]; :::注意:目前Interstitial廣告有相同版位ID在同一台裝置上,每天只會展示一次廣告的限制 :*dealloc _interstitialView.delegate = nil; [_interstitialView release]; _interstitialView = nil; :::建議在廣告呈現的ViewController要release之前,將_interstitialView.delegate設為nil *與Google AdMob整合 :*一般Banner廣告 ::首先將SDK整合至專案中,接著參考https://developers.google.com/mobile-ads-sdk/training/mediation/custom-events/,先設定好Custom Event,最後,在專案中加入Custom Event需要的Class,其中Custom Event的Class Name需要和下面Sample的Class Name保持一致。 #import "TWMTAMediaCustomView.h" #import "GADCustomEventBanner.h" #import "GADCustomEventBannerDelegate.h" #import "TWMTAMediaView.h" @interface TWMTAMediaCustomView () <GADCustomEventBanner, TWMTAMediaViewDelegate> { TWMTAMediaView *adView; } @end @implementation TWMTAMediaCustomView @synthesize delegate; - (void)requestBannerAd:(GADAdSize)adSize parameter:(NSString *)serverParameter label:(NSString *)serverLabel request:(GADCustomEventRequest *)customEventRequest { CGRect frame = CGRectMake(0, 0, adSize.size.width, adSize.size.height); adView = [[TWMTAMediaView alloc] initWithFrame:CGRectMake(0, 0, 320, 50) slotId:serverParameter developerID:@"" gpsEnabled:YES testMode:NO]; adView.delegate = self; [adView receiveAd]; } - (void)viewWillLoadAd:(TWMTAMediaView *)view { NSLog(@"%@ viewWillLoadAd", view); [self.delegate customEventBanner:self didReceiveAd:view]; } - (void)viewDidLoadAd:(TWMTAMediaView *)view { NSLog(@"%@ viewDidLoadAd", view); [self.delegate customEventBanner:self didReceiveAd:view]; } - (void)view:(TWMTAMediaView *)view didFailToReceiveAdWithError:(NSError *)error { NSLog(@"%@ didFailToReceiveAdWithError:%@", view, error.description); [self.delegate customEventBanner:self didFailAd:error]; } - (BOOL)viewActionShouldBegin:(TWMTAMediaView *)view willLeaveApplication:(BOOL)willLeave { NSLog(@"%@ willLeaveApplication:%i", view, willLeave); [self.delegate customEventBannerWillLeaveApplication:self]; return YES; } @end :*Interstitial廣告 #import "TWMTAMediaCustomInterstitialView.h" #import "GADCustomEventInterstitial.h" #import "GADCustomEventInterstitialDelegate.h" #import "TWMTAMediaInterstitialView.h" @interface TWMTAMediaCustomInterstitialView () <GADCustomEventInterstitial, TWMTAMediaInterstitialViewDelegate> { TWMTAMediaInterstitialView *adView; } @end @implementation TWMTAMediaCustomInterstitialView @synthesize delegate; - (void)requestInterstitialAdWithParameter:(NSString *)serverParameter label:(NSString *)serverLabel request:(GADCustomEventRequest *)customEventRequest { CGRect frame = CGRectMake(0, 0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height); adView = [[TWMTAMediaInterstitialView alloc] initWithFrame:frame slotId:serverParameter developerID:@"" gpsEnabled:YES testMode:NO]; adView.delegate = self; [adView receiveAd]; } - (void)presentFromRootViewController:(UIViewController *)rootViewController { CGRect frame = CGRectMake(0, 0, 0, 0); frame.size.width = [UIScreen mainScreen].applicationFrame.size.width; frame.size.height = [UIScreen mainScreen].applicationFrame.size.height; adView.frame = frame; [rootViewController.view addSubview:adView]; [rootViewController.view bringSubviewToFront:adView]; } - (void)interstitialViewWillLoadAd:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewWillLoadAd", view); [self.delegate customEventInterstitial:self didReceiveAd:view]; } - (void)interstitialViewDidLoadAd:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewDidLoadAd", view); [self.delegate customEventInterstitial:self didReceiveAd:view]; } - (void)interstitialView:(TWMTAMediaInterstitialView *)view didFailToReceiveAdWithError:(NSError *)error { NSLog(@"%@ interstitialViewdidFailToReceiveAdWithError:%@", view, error.description); [self.delegate customEventInterstitial:self didFailAd:error]; } - (BOOL)interstitialViewActionShouldBegin:(TWMTAMediaInterstitialView *)view willLeaveApplication:(BOOL)willLeave { NSLog(@"%@ interstitialViewwillLeaveApplication:%i", view, willLeave); [self.delegate customEventInterstitialWillLeaveApplication:self]; return YES; } - (void)interstitialViewWillDisappear:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewWillDisappear", view); [self.delegate customEventInterstitialWillDismiss:self]; } - (void)interstitialViewDidDisappear:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewDidDisappear", view); [self.delegate customEventInterstitialDidDismiss:self]; } @end
返回到「
IOS SDK Developer Guide
」。
導覽選單
個人工具
登入
命名空間
頁面
討論
變體
已展開
已摺疊
視圖
閱讀
檢視原始碼
檢視歷史
更多
已展開
已摺疊
搜尋
導覽
首頁
近期變更
隨機頁面
有關 MediaWiki 的說明
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊