Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>

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?

like image 776
Shilpa M Avatar asked Jul 09 '16 04:07

Shilpa M


People also ask

Where is plist file Xcode?

plist file is available in the Xcode project navigator under Supporting Files. For older project files, Info. plist is located under Resources. Regardless of the selected approach to setting up RUM for your app, add your app identification keys (app ID and beacon URL) to your project's Info.


1 Answers

Use CLLocationManager

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

    <key>NSLocationAlwaysUsageDescription</key>
    <string>Your explanation</string>
    
  • Add the CLLocationManagerDelegate to your swift file

    class ViewController: UIViewController, CLLocationManagerDelegate {...}
    
  • In your viewDidLoad() function, write the following lines :

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

It should work ! Hope I helped you !

like image 50
Damien Ballenghien Avatar answered Sep 18 '22 20:09

Damien Ballenghien