IOS8 Locating Invalid problem-Jeedaa_ios

Source: Internet
Author: User

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;  // Location services available  BOOL enable=[ Cllocationmanager locationservicesenabled];  // have location rights   int Status=[cllocationmanager Authorizationstatus];  if (!enable | | Status<3) { // request permission  [_instance.locationmanager Requestwheninuseauthorization];                /span>      

Look at the enumeration of Authorizationstatus.

typedef ns_enum (int, clauthorizationstatus) {  // user has never chosen permission 0, // cannot use location services, the status user cannot change  Kclauthorizationstatusrestricted, span class= "comment" >// user rejects the app using location services, or the location Services total switch is off  // This value has been deprecated  kclauthorizationstatusauthorized // Generally, the user allows the program to use geographic information whenever it  Kclauthorizationstatusauthorizedalways //< span class= "comment" is roughly the user consent program to use geolocation when visible  Kclauthorizationstatusauthorizedwheninuse};    

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-Jeedaa_ios

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.