gpt4 book ai didi

iOS Swift,didRegisterForRemoteNotificationsWithDeviceToken

转载 作者:行者123 更新时间:2023-11-30 12:53:25 30 4
gpt4 key购买 nike

我需要检查用户是否授予了通知权限,到目前为止我知道只有在授予通知权限时才会调用 didRegisterForRemoteNotificationsWithDeviceToken ,但在某些设备中,无论什么情况都会调用它是否给予许可。有人可以帮我了解如何检查权限状态吗?

didRegisterForRemoteNotificationsWithDeviceToken is getting called even when i deny the permission for notification access.

最佳答案

Swift 3.0 和 Xcode 8

UNUserNotificationCenter.current().delegate = self

UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert], completionHandler: { (granted, error) in
if (granted)
{
UIApplication.shared.registerForRemoteNotifications()
//Allow Push Notification

}
else
{
//Don't Allow Push Notification
}
})

关于iOS Swift,didRegisterForRemoteNotificationsWithDeviceToken,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40690098/

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