Location of map positioning after IOS8

Source: Internet
Author: User

Since iOS8, Apple has further enhanced the protection of users ' privacy.

When the app wants to access the user's privacy information, the system no longer automatically pops up a dialog box to allow the user to authorize

Workaround:

(1) Invoke ios8.0 's API to proactively request user authorization

-(void) requestalwaysauthorization//Request permission to access the user's location on both front and rear stations

-(void) requestwheninuseauthorization//Request permission to get the user's location in the foreground

So now we're going to start using two methods:

Our project of this award gives us the last iOS8 to locate the project we only need to make a slight change:

1. First switch our deployment version to 8.4

2. Then add the following code to the lazy-load location Manager of our VIEWCONTROLLER.M file:

3. Switch the simulator to 6

4. Allow programs

We click on the screen and you'll find nothing to do, no pop-up boxes.

What's the reason for that?

We go into the head file of this method to see

Did you see this sentence?

This means that if you don't have such a key:nslocationwheninuseusagedescription in your info.plist file, then this method won't do anything.

So now we're going to configure this key in the Info.plist file.

After the configuration, we allow the program to see again.

Now we can. Click Allow

Then click on the screen, you will find the console does not print any information, this problem is the simulator problem we just need to restart the simulator can be

Restart the emulator method such as:

And then we re-run the program and you'll find that you can:

Note this: The Requestwheninuseauthorization method By default the wave can get the position in the background need to check the background mode

This time we allow the program to return the program to the background to see the effect

Do you see the difference? A blue bar will appear.

The above is the use of requestwheninuseauthorization for positioning authorization next we look at the requestalwaysauthorization front and rear authorization

The difference between him and requestwheninuseauthorization is that there's no need to tick the background mode and not have blue bars.

At the same time, he also needs to configure the following key in the Info.plist file:

We configure the

Let's simply modify the code to open the front and rear licenses:

Then we run the program:

Found back in the background can still be positioned

The last thing to remind is that the above two methods are ios8.0, so if you're running under 8.0, you're going to report an error that the method can't find, so if you want to fit

Need to determine the current version number of the system

In this position, we've been talking so much since we ios8.0.

Location of map positioning after IOS8

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.