gpt4 book ai didi

ios - 在 native iOS设置中更改位置权限时收到通知

转载 作者:行者123 更新时间:2023-11-29 05:54:55 24 4
gpt4 key购买 nike

我可以将我的Swift应用程序注册到有关位置许可更改的操作系统通知中吗?

例如,假设当前状态为denied,然后用户切换到设置并将权限更改为always,然后再次打开我的应用程序。我可以说出我的用户更改了许可并同时获得了旧的和新的许可,还是问得太多了:)?

类似于ABAddressBookRef ntificationaddressbook = ABAddressBookCreate(); ABAddressBookRegisterExternalChangeCallback(ntificationaddressbook, MyAddressBookExternalChangeCallback, self);

最佳答案

当应用使用以下代码运行时,您只能获取当前的位置权限状态。并据此执行操作。

let status = CLLocationManager.authorizationStatus()
switch status {
case .authorizedAlways:
print("authorizedAlways")
case .authorizedWhenInUse:
print("authorizedWhenInUse")
case .denied:
print("denied")
case .notDetermined:
print("notDetermined")
case .restricted:
print("restricted")
}


正如评论应用中提到的A.Munzer,当您从“设置”应用中更改设置时,该应用将终止。

关于ios - 在 native iOS设置中更改位置权限时收到通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55256140/

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