简体   繁体   中英

How do iOS8 Changes to Location interact with Settings and Alert?

I am converting an iOS7 background location iPhone app to iOS8 and have managed to get the LocationManager to provide coordinates again using many of the suggestions on this site.

I am only interested in requestAlwaysAuthorization not requestWhenInUseAuthorization .

However I cannot ever get iOS to prompt the user for permission to use location services and I am wondering if in some circumstances it should.

Can someone please answer the following questions:

  1. If my Privacy/Location Services/'my app' setting is "Never" does this prevent the app ever receiving GPS coordinates unless the app specifically directs the user to change that setting? (I only seem to receive coordinates if the Privacy/Location Services/'my app' setting is "Always")

  2. Does iOS ever prompt the user to specifically authorise GPS usage (as it used to do in previous iOS versions)? Under what circumstances? If not I assume the app has to raise a suitable UIAlert to direct the user to change Privacy/Location Services/ settings in response to didChangeAuthorizationStatus returning a status of: kCLAuthorizationStatusNotDetermined .

  3. The UIApplicationOpenSettingsURLString can be used to send the user to this app's settings page. However this does not display the Privacy/Location Services/'my app' page which is what the user needs to change if the current setting is preventing coordinates being returned. Is there a different way to programatically direct the user straight to the Privacy/Location Services/'my app' page for this app?

Many thanks for your assistance

Robert

  1. Yes, once the setting is "never" the user will not be prompted by iOS to provide permission - they have given an answer and it is "no". You can display an alert in your app to ask them to turn it on, but if you do this too frequently it will get annoying.

  2. The first time that an App calls requestWhenInUseAuthorization / requestAlwaysAuthorization an alert is displayed. If they user declines to provide location access then the privacy setting is set to "never" and you are in the situation described in question 1. If permission is granted then the privacy setting is set to "when in use" or "always". You should call requestWhenInUseAuthorization / requestAlwaysAuthorization each time your app runs.

  3. There is no way to open the privacy/location settings screen directly from your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM