iOS 12 前台通知shouldAlwaysAlertWhileAppIsForeground崩潰問題


iOS12后,前台通知中

shouldAlwaysAlertWhileAppIsForeground不能使用了,如果還是

 [content setValue:@(YES) forKeyPath:@"shouldAlwaysAlertWhileAppIsForeground"]則會崩潰

 

解決辦法:

Appdelegate中添加:

//iOS 12
-(void) userNotificationCenter:(UNUserNotificationCenter*)center willPresentNotification:(UNNotification*)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
    completionHandler(UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionSound);
}

 

創建前台通知時不設置

shouldAlwaysAlertWhileAppIsForeground屬性。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM