gpt4 book ai didi

ios - isRegisteredForRemoteNotifications 返回 true 即使我完全禁用它

转载 作者:IT王子 更新时间:2023-10-29 05:29:59 24 4
gpt4 key购买 nike

if UIApplication.sharedApplication().isRegisteredForRemoteNotifications() == true {
println("Yes, allowed")
println(UIApplication.sharedApplication().isRegisteredForRemoteNotifications())
} else {
//ignore
return
}

当我转到设置以完全关闭通知然后返回应用程序时,该应用程序仍然打印 true, allowed。

我似乎无法让它触发 false,即使在应用程序卸载/重新安装之后也是如此。

最佳答案

我为 Swift 3 做了一个扩展

extension UIApplication {
func remoteNotificationsEnabled() -> Bool {
var notificationsEnabled = false
if let userNotificationSettings = currentUserNotificationSettings {
notificationsEnabled = userNotificationSettings.types.contains(.alert)
}
return notificationsEnabled
}
}

比起使用它

UIApplication.shared.remoteNotificationsEnabled()

关于ios - isRegisteredForRemoteNotifications 返回 true 即使我完全禁用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29787736/

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