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屬性。