簡體   English   中英

位置服務提醒

[英]Location service alert

我們可以通過不關閉應用程序並轉到設置頁面來調用位置服務警報再次彈出。像一些用戶不知道他們是否必須在彈出后選擇“允許或不允許”。該問題的任何解決方案。

如果您的要求是提醒用戶他的位置服務狀態,您可以提供自己的警報,並可以將用戶導航到“設置”頁面。

      - (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"]];
            }

        }

不幸的是,除非設備是Jailbroken,否則不可能這樣做。 但是,將用戶路由到設置窗格中的正確區域相對簡單。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM