8

I'm using phonegap to make an app, and when a user doesn't allow a certain permission (GPS for example), then the app doesn't ask again the next time they use that feature and I thought the best I could do is just display a message like this:

Please go to iOS Settings > Privacy > Location Services to enable the app to access your location

But I just noticed that the maps app give this message:

Turn On Location Services to Allow Maps to Determine Your Location

And it has the option of Settings or Cancel. If you click Settings, it takes you right to the location services part of settings so that you can enable it.

My question is, how can I link to that part of settings with a phonegap app?

aharris88
  • 3,560
  • 3
  • 27
  • 45

1 Answers1

2

In iOS >= 8 you can open the application setting panel using:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];

It's very easy to write a cordova plugin that open that panel from the js layer. To make a portable and stable plugin you should check for the existence of that variable before using it (in iOS < 8).

See the iOS UIApplication documentation for more information.

Ore use an existing cordova settings plugin.

lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
  • Is it possible to actually go to the " iOS Settings > Privacy > Location Services"? The mentioned plugin works perfectly as a tool to go your Application Settings, but does not work for going into the Location Services settings screen. If the user has completely disabled Location Services, going to your Application Settings does not help. This thread http://stackoverflow.com/questions/23824054/how-to-open-settings-programmatically-like-in-facebook-app seems to suggest it's not possible. – Sandro Gržičić Apr 15 '16 at 16:49
  • From what I remember this isn't possible, so the link should be right. But keep in mind that this kind of things changes over time. Keep searching and learning. – lifeisfoo Apr 17 '16 at 06:16