SDK8 iOS注意事項
於 2021年8月5日 (四) 11:31 由 imported>Wikiuser 所做的修訂 (新頁面: 回iOS首頁<br> == SDK 7 升版至 SDK 8 == SDK 8 對 SDK 及廣告類型做了以下調整 # 移除在 SDK 7 加入的 OMSDK_Taiwanmobile.framework<br...)
SDK 7 升版至 SDK 8
SDK 8 對 SDK 及廣告類型做了以下調整
- 移除在 SDK 7 加入的 OMSDK_Taiwanmobile.framework
SDK 8 已經將 OMSDK 整合進 TAMediaFramework 內,故 SDK 7 的使用者,請在升級 SDK 8 時將它移除 - 廢棄 TADInReadAdRect 廣告
SDK 8 將不在提供 TADInReadAdRect 廣告,可以使用 Banner 1200x627 或是 Native 廣告取代 - TADNativeAd 廢棄 getNativeAdContent 與 handleClick function,新增 TADNativeAdView 來呈現廣告,詳細串接方式請參考 NativeAd
麥克風相關
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;
}
}