Location Services not working in iOS 11

前端 未结 8 577
春和景丽
春和景丽 2020-11-27 14:59

I just rebuilt my app with the iOS 11 SDK in an attempt to remove the blue banner that is now always appearing. I thought - \"Brilliant, that worked\", only to

8条回答
  •  臣服心动
    2020-11-27 15:17

    Just to add the steps on fixing this:

    2 ways to do it:

    A) The easy way: Select your Info.plist file, add the properties, note that they start with PRIVCY instead of LOCATION... therefore, the exact names of these variables starts with "Privacy - Location ... " etc, add each here, and describe how the user would be seeing this on the warning.

    B) The hard / interesting / programatic way (I like this way more):

    Right click on your Info.plist for your app, and then select "View source code", you should see it all in XML,

    Follow the other ...... format, and add these properties as follows:

    NSLocationAlwaysUsageDescription
    Program requires GPS to track cars and job orders
    NSLocationAlwaysAndWhenInUseUsageDescription
    Program requires GPS to track cars and job orders
    NSLocationWhenInUseUsageDescription
    Program requires GPS to track cars and job orders
    NSMicrophoneUsageDescription
    This app uses your Microphone to allow Voice over IP communication with the Program Admin system
    

    Save, and then right-click on the info.plist file, and then select Property list, this should view the file back into the default view.

    EDIT:

    Another member asked for code, here it is:

    1) On your .H file, add:

    @property (strong, nonatomic) CLLocationManager *LocationManager;
    

    2) On your .M file add under ViewDidAppear() function:

    _LocationManager = [[CLLocationManager alloc] init];
    [_LocationManager setDelegate:self];
    _LocationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
    _LocationManager.pausesLocationUpdatesAutomatically = NO;
    [_LocationManager requestAlwaysAuthorization];
    
    _LocationManager.headingFilter = 5;
    _LocationManager.distanceFilter = 0;
    
    [_LocationManager startUpdatingLocation];
    [_LocationManager startUpdatingHeading];
    

    This what works fine for me, hopefully the code would work for you too.

    Regards

    Heider

提交回复
热议问题