One of my programs, used to be useful, including IOS6,IOS7, but the phone upgrade to IOS8, Xcode6 compile and run, it will not work properly, nor error. The phenomenon is to go into the settings privacy-location services to find this application, set to always allow, the normal access to geographic information, but then recompile the run, it will become this unknown state.
after thinking about it before reloading the app and then call the location service will pop up the authorization dialog box, but IOS8 did not play, so join the call Locationmanager requestalwaysauthorization manually request authorization, You can then monitor whether you can have location permissions in the Didchangeauthorizationstatus callback. But there are a few things to be aware of when you call this request, it pops up in the dialog box that the query, need our own designation. So you need to add a key:nslocationalwaysusagedescription,value inside the info.plist that is the statement that you want to ask on the dialog box. At this time the program can correctly pop up the authorization dialog box, the user chose the consent, positioning the code to run correctly.
_instance.locationmanager = [[Cllocationmanager alloc] init];//Create a location manager_instance.locationmanager.Delegate=_instance; _instance.locationmanager.desiredaccuracy=kcllocationaccuracybest; _instance.locationmanager.distancefilter=100.0f; _instance.updating=NO; //whether location services are availableBOOL enable=[Cllocationmanager locationservicesenabled]; //whether to have location permissions intstatus=[Cllocationmanager Authorizationstatus]; if(!enable | | status<3){ //Request Permission[_instance.locationmanager requestwheninuseauthorization]; }
Look at the enumeration of Authorizationstatus.
typedef ns_enum (int, Clauthorizationstatus) { //The user has never selected a permissionkclauthorizationstatusnotdetermined =0, //cannot use location services, the status user cannot changekclauthorizationstatusrestricted,//the user rejects the app using location services, or the location Services total switch is offkclauthorizationstatusdenied,//This value has been deprecatedKclauthorizationstatusauthorized//the user is generally allowed to use geographic information whenever the program isKclauthorizationstatusauthorizedalways//generally the user agrees that the program uses a geographic location when it is visibleKclauthorizationstatusauthorizedwheninuse};
That is, [Cllocationmanager authorizationstatus] returns greater than or equal to 3 o'clock is the use of location services.
The problem is that in previous versions of iOS, when you started using location services, the Ask for Authorization dialog box automatically pops up, and now IOS8 needs to manually call Locationmanager Requestalwaysauthorization to manually request authorization. To get location permissions.
IOS8 Locating Invalid problem