为什么在重新安装iOS App后不出现位置权限弹出窗口?

时间:2018-06-29 20:08:15

标签: ios objective-c cllocationmanager

使用CLLocationManager获取当前位置时,我遇到一个奇怪的问题。第一次请求当前位置时,我会看到具有允许不允许选项的权限弹出窗口。我选择了不允许,然后通过选择使用应用程序时转到“应用程序设置”和“打开位置”,然后返回到该应用程序并卸载该应用程序。当我重新安装同一个ipa文件时,我没有再次获得权限弹出窗口。

观察:在调试应用程序时,我知道第一次安装应用程序并请求位置更新时,我收到的是 AuthorizationStatus = kCLAuthorizationStatusNotDetermined ,然后从那里我叫 requestWhenInUseAuthorization ,但是当我重新安装应用而不是kCLAuthorizationStatusNotDetermined AuthorizationStatus 时,我直接得到了 requestWhenInUseAuthorization 。我已经在带有iOS 10的iPhone 7 Plus中观察到了此问题。我已经在我的info.plist文件中添加了权限密钥。 enter image description here

请找到我在应用程序中使用的代码段。

- (Void)getCurrentLocation {
    // Check if location services enabled in settings..
        if ([CLLocationManager locationServicesEnabled]) {
            locationManager = [[CLLocationManager alloc] init];
            locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
            locationManager.delegate = self;
        }
        else{
            NSLog(@"Location Services Turn Off");
        }
    }

  [1]: https://i.stack.imgur.com/vo4An.png



    #pragma mark- CoreLocation Delegate Methods

        // This will be called when app level location permissions are changed.
    - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
        NSLog(@"didChangeStatus called.. status: %d", status);
        switch (status) {
            case kCLAuthorizationStatusNotDetermined:{
                NSLog(@"kCLAuthorizationStatusNotDetermined");
                [locationManager requestWhenInUseAuthorization];
            }
            break;
            case kCLAuthorizationStatusRestricted:{
                NSLog(@"kCLAuthorizationStatusRestricted");
            }
            break;
            case kCLAuthorizationStatusDenied:
            {
                NSLog(@"kCLAuthorizationStatusDenied");
            }
            break;
            default:{
                [locationManager startUpdatingLocation];
            }
            break;
        }
    }

    // This delegate method will be called in case of iOS 6 or later when location data is fetched successfully.
    - (void)locationManager:(CLLocationManager *)manager
    didUpdateLocations:(NSArray *)locations{
        CLLocation* receivedLocation = [locations lastObject];
        [self formatLocationData:receivedLocation];
    }

请检查并让我知道重新安装相同的ipa文件时如何获得“位置许可权”弹出窗口。

0 个答案:

没有答案