从 OS 11.2.5 开始,我的设备无法注册远程通知(例如,出于静默推送的目的。我在以下代码行中实现了注册过程:
// Ask for notification permission
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {(accepted, error) in
if !accepted {
print("Notification access denied.")
}
}
application.registerForRemoteNotifications()
此外,如您所知,您需要实现以下两种方法,以便在 Apple 注册远程通知:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenParts = deviceToken.map { data -> String in
return String(format: "%02.2hhx", data)
}
let token = tokenParts.joined()
// Get my token here and do additionally stuff
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
// Handling error for registering here
}
所以我的问题如下:此实现一直有效,直到 Apple OS 更新 11.2.4:didRegisterForRemoteNotificationsWithDeviceToken注册设备后成功调用,如果出现错误,didFailToRegisterForRemoteNotificationsWithError则调用其他方法 -> 一切都很完美!
但从 OS 11.2.5 开始,我再也没有得到 Apple 的回应。我花了很多时间研究这个问题。在 Apple 发布 OS 11.2.6 之后,它又像魅力一样工作了 -> 我完全糊涂了。
有人知道这是否是 OS 11.2.5 中的一个已知问题?- 谢谢亚历克斯