IOS注意事項

出自TAMedia
於 2018年7月26日 (四) 02:03 由 imported>Wikiuser 所做的修訂 →‎舊版SDK升版至SDK6
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
跳至導覽 跳至搜尋

回iOS首頁

舊版SDK升版至SDK6

  1. 移除下列檔案:
    • libTWMTAMediaAdsSDK.a
    • TADAdSize.h
    • TADBannerView.h
    • TADBannerViewDelegate.h
    • TADInterstitial.h
    • TADInterstitialDelegate.h
    • TADRequest.h
    • TADRequestError.h
    • TADNativeAd.h
    • TADNativeAdDelegate.h
    • TADVideoAdView.h
    • TADVideoAdViewDelegate.h
    • TAMClose.png
    • facebook.png
    • TAMTarget.png
    • mute.caf
  2. 專案加入TAMediaAdsFramework.framework
  3. 將程式碼內有加入TAMedia標頭檔.h的地方皆改為#import <TAMediaAdsFramework/TAMediaAdsFramework.h>

麥克風相關

TADBannerView以及TADInterstitial新增turnOnMicrophone屬性,設為YES時會與使用者詢問是否開啟麥克風,故需於app info中要設定Privacy - Microphone Usage Description。 若是設為NO,將不提供有麥克風互動式廣告,default設為YES。

音樂類型app

因為SDK4支援麥克風互動式ad,若是ad開啟麥克風功能,會導致播放音樂時狀態被搶走,造成關閉ad後音樂無法持續播放。 已提供解決方案(參見下方說明),或是可以直接拒絕接收麥克風ad,將turnOnMicrophone設為NO。

解決中斷音樂回覆方法為監聽AVAudioSessionInterruptionNotification(若是有處理回復來電時中斷音樂的情況原本已經有監聽,只需新增標示處的code,於收到中斷時將music暫停,中斷結束時將music重新播放。 範例如下:

// 增加監聽   
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioSessionInterrupted:) name:AVAudioSessionInterruptionNotification object:nil];
// 監聽Session被中斷時,先暫停音樂  
-  (void)audioSessionInterrupted:(NSNotification*)notification {
   NSNumber *interruptionType = [[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey];
   NSNumber *interruptionOption = [[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey];
   switch (interruptionType.unsignedIntegerValue) {
       case AVAudioSessionInterruptionTypeBegan:{
           // • Audio has stopped, already inactive
           // • Change state of UI, etc., to reflect non-playing state
           [_audioPlayer pause]; //若原本就有處理來電中斷音樂只需新增此段code
       } break;
       case AVAudioSessionInterruptionTypeEnded:{
           // • Make session active
           [[AVAudioSession sharedInstance] setActive:YES withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:nil];
           // • Update user interface
           // • AVAudioSessionInterruptionOptionShouldResume option
           if (interruptionOption.unsignedIntegerValue == AVAudioSessionInterruptionOptionShouldResume) {
               // Here you should continue playback.
               [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
               [_audioPlayer play];
           }
       } break;
       default:
           break;
   }  
 }  


回 iOS首頁