PromiseKit / CoreLocation

Promises for Swift & ObjC
http://promisekit.org
MIT License
30 stars 29 forks source link

There is no way to request location permission after the user denied it in the past, using requestAuthorization #19

Closed ariofrio closed 6 years ago

ariofrio commented 6 years ago

While many apps would do best not to ask for location permission after the user has denied it in the past, since they can make do without location information, some apps require location for features to work, so it makes sense to ask the user to provide permission when they try to use the feature again.

The way the API is defined, it doesn't allow the programmer to implement this functionality. It only asks for permission if permission has never been asked for in the past. If the user has denied it, then it will never ask for permission again.

See the lines:

        if currentStatus == .notDetermined {

and

            case .notDetermined, .authorizedWhenInUse:

A more flexible API would always ask for permission, and let the programmer check if the current status is .denied to skip asking for permission.

But I imagine changing the API in a backwards incompatible way would not be good. I propose adding a parameter to requestAuthorization "skipIfPreviouslyDenied" which defaults to true.

ariofrio commented 6 years ago

Actually, this would apply to both .denied and .restricted, so "skipIfPreviouslyDenied" would be a misnomer.

Alternatives: "skipIfPreviouslyDeniedOrRestricted", "skipIfDeniedOrRestricted", "onlyIfNotDeterminedOrUpgrade".

Or the inverse: "ifDeniedOrRestricted"


Or two optional arguments: ifDenied and ifRestricted.

ariofrio commented 6 years ago

Never mind. I thought that apps were allowed to ask for permission after it has been denied, because the Apple Maps app can do that. When testing my own app, however, asking for permission more than once did nothing.

I will probably end up showing a message to the user asking them to change their settings and then redirecting them to the app settings page when this happens.

mxcl commented 6 years ago

Yeah, the underlying API does not allow this. Apple must give themselves special permissions.