【问题标题】:requestWhenInUseAuthorization and requestAlwaysAuthorizationrequestWhenInUseAuthorization 和 requestAlwaysAuthorization
【发布时间】:2016-02-07 03:13:03
【问题描述】:

我在 plist 上有这段代码:

<key>NSLocationUsageDescription</key> <string>Usage</string>
<key>NSLocationWhenInUsageDescription</key> <string>WhenIn</string>
<key>NSLocationAlwaysUsageDescription</key> <string>Always</string>

这个在 viewController 的 viewDidLoad 上:

 self.locationManager.requestWhenInUseAuthorization()
 self.locationManager.requestAlwaysAuthorization()

但是 requestWhenInUseAuthorization() 警报没有出现。只能“在后台使用”。这是正常的吗?有什么问题?

谢谢

【问题讨论】:

  • 如果使用requestAlwaysAuthorization,则不需要requestWhenInUseAuthorization,因为“always”包括in use和background的case

标签: ios swift plist cllocationmanager


【解决方案1】:

您在 plist 中的“NSLocationWhenInUsageDescription”键错误,将其更改为“NSLocationWhenInUseUsageDescription”。

请求的顺序也会影响系统将向用户显示的警报,因为它只会显示第一个请求警报(在您的情况下为“使用时”),但它会将它们都添加到设置,并将选择您请求的第一个

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 2014-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-26
    • 2014-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多