gpt4 book ai didi

swift - 如何在 swift 3 中获取通知授权状态?

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

如何在 iOS 11 中检查 UNUserNotificationCenter 的当前授权状态?我一直在寻找一段时间并找到了一些代码,但它不在 swift 3 中,并且某些功能在 iOS 10 中已被弃用。有人可以帮忙吗?

最佳答案

好的,我找到了:

let center = UNUserNotificationCenter.current()
center.getNotificationSettings { (settings) in
if(settings.authorizationStatus == .authorized)
{
print("Push authorized")
}
else
{
print("Push not authorized")
}
}

代码:Kuba

关于swift - 如何在 swift 3 中获取通知授权状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46457733/

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