简体   繁体   中英

Location service alert

我们可以通过不关闭应用程序并转到设置页面来调用位置服务警报再次弹出。像一些用户不知道他们是否必须在弹出后选择“允许或不允许”。该问题的任何解决方案。

If your requirment is to remind the user about his location service status, you can provide your own alert about it, and can navigate user to Settings page.

      - (void) showLocationAlert {

                if ([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) {

                        //Check whether Settings page is openable (iOS 5.1 not allows Settings page to be opened via openURL:)
                        if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]) {
                            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"You must enable location service,Turn on location service to allow \"YourApp\" to determine your location" delegate:self cancelButtonTitle:@"Settings" otherButtonTitles:@"Cancel", nil];
                            [alert show];

                        }
                        else {
                            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"You must enable location service" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
                            [alert show];
                        }
                 }
            }



  - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  {
          if (buttonIndex == 0) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]];
            }

        }

Unfortunately, it is not possible to do so unless the device is Jailbroken. However, it is relatively simple to route the user to the correct area in the settings pane.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM