在info.plist中添加的NSLocationAlwaysUsageDescription字符串未显示在权限弹出iOS中 [英] NSLocationAlwaysUsageDescription string added in info.plist is not showing in permission popup ios

查看:1503
本文介绍了在info.plist中添加的NSLocationAlwaysUsageDescription字符串未显示在权限弹出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中添加了此内容。权限弹出窗口仍然不显示添加的字符串,而是显示-
即使不使用应用程序,也允许应用程序访问您的位置吗?

I have added this in info.plist. Still the permission popup does not shows the string added,Instead it shows-- Allow "app" to access your location even when you are not using the app?

推荐答案

使用CLLocationManager


  • 添加以下行在您的Info.plist文件中(右clic->打开为->源代码)

  • Add the following line in your Info.plist file (right clic -> Open as -> Source Code)

<key>NSLocationAlwaysUsageDescription</key>
<string>Your explanation</string>


  • 将CLLocationManagerDelegate添加到您的快捷文件中

  • Add the CLLocationManagerDelegate to your swift file

    class ViewController: UIViewController, CLLocationManagerDelegate {...}
    


  • 在viewDidLoad()函数中,编写以下几行:

  • In your viewDidLoad() function, write the following lines :

    var locationManager : CLLocationManager = CLLocationManager()
    locationManager.delegate = self
    locationManager.requestAlwaysAuthorization()
    


  • 应该可以!希望我能帮助您!

    It should work ! Hope I helped you !

    这篇关于在info.plist中添加的NSLocationAlwaysUsageDescription字符串未显示在权限弹出iOS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆