Reputation: 6620
I am trying to get the geolocation of the iOS device. I am able to get the coordinates of the present location using CoreLocation framework.
But the problem is I have to handle the scenario when location services has been disabled from device settings. In that case, I have to redirect the user to settings from within my app as per the requirement.
I know that I can do this using the below scheme prior to iOS 5.1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];
But, how to handle this in this newer releases. I am stuck with this since a long time and no solution yet. Please advise.
Upvotes: 1
Views: 4455
Reputation: 1867
@Rashmi - You might be getting some trouble some where else.
CoreLocation Framework automatically detects if the Location Settings are disabled from the Device via generating an alert and take you automatically to the device settings.I had verified this in iOS7, iOS6 devices.
Moreover, I Googled and found that this is the only way to open setting from the app and that matches with you have written.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];
You can also follow this URL for reference Open Device Settings from the app
For Core Location, You can see this demo CoreLocation
Upvotes: 1
Reputation: 131
You should call: [CLLocationManager locationServicesEnabled]
As it states here:
Upvotes: 1