ios - How can I prompt the user to turn on location services after user has denied their use -
i have application explicit user interaction makes use of user's current location. if user denies access location services, still subsequent uses prompt user go settings , re-enable location services app.
the behavior want of built-in maps app:
- reset location warnings in settings > general > reset > reset location warnings.
- start maps app.
- tap current location button in lower left corner.
- maps prompts ""maps" use current location" | "don't allow" | "allow".
- choose "don't allow" option.
- tap current location button in lower left corner again.
- maps prompts "turn on location services allow "maps" determine location" | "settings" | "cancel".
in own app, same basic flow results in cllocationmanagerdelegate -locationmanager:didfailwitherror: method being called kclerrordenied error @ final step , user not given option open settings app correct it.
i display own alert in response error, not have ability launch settings app alert os can provide used built-in maps app.
is there in cllocationmanager class missing able give me behavior?
with ios8, can link user settings app via openurl. example, can create uialertview single button takes user settings app:
uialertview *alert = [[uialertview alloc] initwithtitle:iclocalizedstring(@"locationservicespermissiontitle") message:iclocalizedstring(@"locationpermissiongeofencemessage") delegate:self cancelbuttontitle:@"settings" otherbuttontitles:nil]; [alert show];
in uialertview delegate:
- (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { [alertview dismisswithclickedbuttonindex:buttonindex animated:yes]; [[uiapplication sharedapplication] openurl: [nsurl urlwithstring: uiapplicationopensettingsurlstring]]; }
Comments
Post a Comment