Question

In my app,I want to show user location in one of my UIViewController which uses MKMapKit.So when the user selects this View Controller they will be asked whether to allow or don't allow. If user selects allow, then everything fine.If they selects don't allow, then the user is never asked again to allow or not.

Actually what I want is, when user selects don't allow for the first time when they are using my app, they should be asked to select again to allow or don't allow for the next time they uses the app. So how can I achieve this? When the user selects allow for the select time (first time they clicked not allowed), then my app show the user location.

Even in some S.O question,many have suggested that the user will be promoted to allow or don't allow alert whenever they open the app.But for me its asking for the first time app used.

Please share your ideas. Thank you.

Was it helpful?

Solution

If the user has turned off location services for your app the first time, you will know in your application every time you try to get their location. You can check if the user has given you permission to read their location or not. In case they haven't, they will be prompted again to enable location services for your app.

Quoting from Apple's documentation (found here)

it is recommended that you always call the locationServicesEnabled class method of CLLocationManager before attempting to start either the standard or significant-change location services. (In iOS 3.x and earlier, check the value of the locationServicesEnabled property instead.) If this class method returns YES, you can start location services as planned. If it returns NO and you attempt to start location services anyway, the system prompts the user to confirm whether location services should be reenabled. Given that location services are very likely to be disabled on purpose, the user might not welcome this prompt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top