iOS 12 前臺通知shouldAlwaysAlertWhileAppIsForeground崩潰問題

iOS12後,前臺通知中blog

shouldAlwaysAlertWhileAppIsForeground不能使用了,若是仍是it

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

 

解決辦法:class

Appdelegate中添加:notification

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

 

建立前臺通知時不設置di

shouldAlwaysAlertWhileAppIsForeground屬性。co

相關文章
相關標籤/搜索