![](/img/trans.png)
[英]iOS locationmanager doesn't ask user permission even with NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription in Info.plist
[英]NSLocationAlwaysUsageDescription string added in info.plist is not showing in permission popup ios
<key>NSLocationAlwaysUsageDescription</key>
<array>
<string>Location is required to find out where you are</string>
</array>
<key>Privacy-Location Usage Description</key>
<string>Location is required to find out where you are.</string>
我在info.plist中添加了这个。 仍然权限弹出窗口没有显示添加的字符串,而是显示 - 即使您不使用应用程序,也允许“app”访问您的位置?
使用CLLocationManager
在Info.plist文件中添加以下行(右侧clic - >打开为 - >源代码)
<key>NSLocationAlwaysUsageDescription</key> <string>Your explanation</string>
将CLLocationManagerDelegate添加到swift文件中
class ViewController: UIViewController, CLLocationManagerDelegate {...}
在viewDidLoad()函数中,写下以下行:
var locationManager : CLLocationManager = CLLocationManager() locationManager.delegate = self locationManager.requestAlwaysAuthorization()
它应该工作! 希望我能帮助你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.