Lukas Kurz
Lukas Kurz

Reputation: 85

Best Practice way to handle locationAlways permission request in iOS

How are we supposed to handle, when a user denies the permission request for kCLAuthorizationStatusAuthorizedAlways ? As i understand it, we don't get a direct response to requestAlwaysAuthorization, but rather we have to register a callback for locationManagerDidChangeAuthorization, which only gets called, if status is undetermined or is changed. Since we first have to request whenInUse permission with requestWhenInUseAuthorization, the status is no longer undetermined once we request always permission. Furthermore, since the "deny" option is "keep when in use permission", the actual permission is not changed if the request is denied, hence the callback won't be called. So how are we supposed to know the request was denied by the user, so we can point them towards the settings ?

A bit of context: I am developing an App in Flutter, where I need the kCLAuthorizationStatusAuthorizedAlways. For this, I use a library called permission_handler, which has native (objective c) code for iOS. Sadly, it has a bug, and since I need it to work, I am going to try to fix it myself.

Looking through the code, I suspect the problem stems from the callback not being called in the "deny" case, so I am trying to figure out how to obtain the information, that the request was denied, so I can return this information from the plugin to the FlutterEngine, where my flutter code is run.

You don't have to understand any Flutter or Dart to explain/understand this, as I just want to know how you would handle this situation in a native iOS app, so I can understand it and apply that knowledge to my flutter app/the library.

Thanks for taking the time to read my question and helping me!

Upvotes: 0

Views: 368

Answers (0)

Related Questions