Requesting in use authorization shows no prompt

社会主义新天地 提交于 2020-01-06 09:09:34

问题


I have

NSLocationWhenInUseUsageDescription

and

NSLocationAlwaysUsageDescription

defined in my Info.plist.

In my code I do

    if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [_locationManager requestWhenInUseAuthorization];
    }

    [_locationManager startUpdatingLocation];

And I don't get prompted on iOS8.

I did a clean reinstall in my simulator. On iOS7 without the 3 if block I get prompted.

Right after startUpdatingLocation I check [CLLocationManager authorizationStatus] which is 0- kCLAuthorizationStatusNotDetermined

How do I prompt iOS8 users?


回答1:


4 ios 8: Need configure it in info.plist,

key name as "NSLocationAlwaysUsageDescription" value as ""

key name as "NSLocationWhenInUseUsageDescription" value as ""

When you called:

[_locationManager requestWhenInUseAuthorization];

will be auto prompt.

Testing with simulator, you can click "Reset content and settings..." and prompt again.

Here is a demo : https://github.com/JNYJ/001PGWUcurrentWULF



来源:https://stackoverflow.com/questions/26923409/requesting-in-use-authorization-shows-no-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!