我是靠谱客的博主 酷酷花卷,这篇文章主要介绍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属性。

转载于:https://www.cnblogs.com/Ganggang888/p/9706279.html

最后

以上就是酷酷花卷最近收集整理的关于iOS 12 前台通知shouldAlwaysAlertWhileAppIsForeground崩溃问题的全部内容,更多相关iOS内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(118)

评论列表共有 0 条评论

立即
投稿
返回
顶部