Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asking user permission for accessing their location with iOS when mapView does

I've developed an app using a MapView - when the app starts up, it asks the user to allow their location to be accessed/used without any coding from me. Is this sufficient for permission or should I also specifically ask the user and provide a reason for the access? Will Apple reject the app on submission if I don't specifically make the request and allow the MapView to request this on my behalf?

like image 276
Jonny Wilson Avatar asked Nov 30 '22 14:11

Jonny Wilson


2 Answers

You don't need to ask the user for permission, iOS does it for you automatically.

You should set the purpose string property in the CLLocationManager object so that when the system asks it can also tell the user why you want their location.

locationManager.purpose = @"Location needed to show zombies that are nearby.";

Set this property before calling startUpdatingLocation so that it gets shown to the user in the system alert that asks for permission to use location.

In the delegate you can implement the method locationManager:didChangeAuthorizationStatus: to know whether the user allowed core location or not.

like image 158
progrmr Avatar answered Dec 18 '22 01:12

progrmr


As of iOS 6, the correct place for the "purpose" message is in the Info plist file.

The NSLocationUsageDescription property should be set with the message to display to users

Apple provides good documentation: https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

like image 35
Jon Deokule Avatar answered Dec 17 '22 23:12

Jon Deokule