在iOS 11之前,当应用程序在前台运行时收到通知时,通知将不会出现,除非使用自定义视图显示它。在iOS 11中,当应用在前台运行时,我们处理收到的推送通知的方式是否发生了变化?
发布于 2017-11-02 17:59:09
在Appdelegate类中尝试此操作
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}这是当应用程序处于前台时的委托调用,如果您还想显示警报,则在completionHandler中添加.alert。
它在iOS 10及更高版本中添加
https://stackoverflow.com/questions/47072259
复制相似问题