1

I have an app which uses location services and background app refresh, I want to include these 2 preferences in my own app's Settings page so that the User can do this in one place rather than going to settings App.

Is it possible in iOS7 or iOS8? I know a few apps which are doing this.

  • Yes you can do, it just if disabled in your app preference don't use Location, or Background Refresh code which might be initialising your services. But in case of Background Refresh if not disabled through Settings it will try to call. – iphonic Aug 19 '15 at 05:14
  • Hello Nupur, was my answer was helpful? – Mithun Ravindran Aug 20 '15 at 04:21

1 Answers1

0

The initial Alert which will prompt to get location service for an app is triggered by the OS and not by the App. This will be triggered as you would have enabled location based settings in your application.

But if the user deny it for the first time, according to the OS the user prefer to deny the location service for that particular app and this is users privacy. As Apple is very much concerned about user’s privacy settings, for user to accept those settings again, they should explicitly enable it again from the settings App and it is not possible to achieve it from app level. Because its nothing to do with the app and its purely OS based, and as a developer we cannot override it.

Instead we can detect the users current privacy setting for location, and if status in not having access, then you may prompt user an alert on which user may directly change the settings after navigating to settings app.

if([CLLocationManager locationServicesEnabled]){

    if([CLLocationManager authorizationStatus]==kCLAuthorizationStatusDenied){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ICLocalizedString(@"LocationServicesPermissionTitle")
                                                message:ICLocalizedString(@"LocationPermissionGeoFenceMessage")
                                               delegate:self
                                      cancelButtonTitle:@"Settings"
                                      otherButtonTitles:nil];
        [alert show];
    }
}

UIAlertView delegate:

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{
    [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString: UIApplicationOpenSettingsURLString]];
}
Mithun Ravindran
  • 2,292
  • 2
  • 14
  • 23