Search code examples
iosswiftxcodelocation

How to ask users to always use the 'precise location' option?


enter image description here

Hello. I'm making an app that organizes the user's movement records when hiking. So I want to encourage users to use the Precise Location option all the time.

However, I saw a lot of pop-ups asking me to set location permissions on other apps, but I couldn't find a pop-up or UX asking me to turn on the Precise Location that was turned off. Is it against Apple's policy to ask for this?

If you don't violate it, I'd like to know how other apps ask users to turn on their permissions.

Thank you.


Solution

  • You can use CLLocationManager's CLAccuracyAuthorization property to determine whether the user has full/reduced accuracy. Note that this is available from iOS 14 / macOS 11.

    switch locationManager.accuracyAuthorization {
        case .fullAccuracy:
            // TODO: handle fullAccuracy
        case .reducedAccuracy:
            // TODO: handle reducedAccuracy - request temporary full accuracy
        @unknown default:
            // TODO: handle default
    }
    

    If the result is .reducedAccuracy, you can use requestTemporaryFullAccuracyAuthorization(withPurposeKey:completion:) to request temporary access to .fullAccuracy.

    Don't forget to fill in NSLocationTemporaryUsageDescriptionDictionary and use appropriate key in the function above.

    It would look something like this

    enter image description here