【问题标题】:NSLocationAlwaysUsageDescription string added in info.plist is not showing in permission popup ios在 info.plist 中添加的 NSLocationAlwaysUsageDescription 字符串未显示在权限弹出 ios 中
【发布时间】:2016-07-09 04:09:03
【问题描述】:
<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 中添加了这个。权限弹出窗口仍然没有显示添加的字符串,而是显示-- 即使您不使用该应用,也允许“应用”访问您的位置?

【问题讨论】:

  • 你在模拟器或设备上试过吗

标签: ios cllocationmanager


【解决方案1】:

使用 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()
    

它应该工作!希望对你有帮助!

【讨论】:

  • 嘿,谢谢,开始工作了。我不得不删除 info.plist 中的 标签
猜你喜欢
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 2021-09-21
  • 2016-01-28
  • 1970-01-01
  • 2021-10-15
  • 1970-01-01
  • 2013-10-03
相关资源
最近更新 更多