gpt4 book ai didi

iOS 9 推送通知在应用程序打开时不显示

转载 作者:行者123 更新时间:2023-11-28 19:42:57 25 4
gpt4 key购买 nike

if (deviceToken == nil) {
print("There is no deviceToken saved yet.")
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
}

这是我的权限代码。

最佳答案

Need to add the completionHandler part, otherwise push notification is received. but it will be not shown.

@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (_ options: UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
}

关于iOS 9 推送通知在应用程序打开时不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33626159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com