Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS requestLocationAuthorization's success callback executes immediately #35

Closed
zarko-tg opened this issue Feb 9, 2016 · 1 comment
Closed

Comments

@zarko-tg
Copy link

zarko-tg commented Feb 9, 2016

User if this is a bug or a problem with the wording in the documentation.

The success callback function of requestLocationAuthorization is being called immediately / as soon as the dialog is shown on iOS. My expectation is that it must be called once the user allows usage of device location, as it already does so on Android.

Experienced on a iOS 9.3 iPhone 6.

@dpa99c
Copy link
Owner

dpa99c commented Feb 12, 2016

I need to make this clearer in the documentation.

On Android (6+), requestLocationAuthorization(success, error) is an alias for:

Diagnostic.requestRuntimePermissions(success, error, [
    Diagnostic.runtimePermission.ACCESS_COARSE_LOCATION,
    Diagnostic.runtimePermission.ACCESS_FINE_LOCATION
]);

Hence the success callback is invoked in response to the user's choice in the dialog and is passed the resulting outcome.

On, iOS it works differently: when requestLocationAuthorization() is called, the resulting dialog is invoke on a different thread. In order to listen for the response, you currently need to use registerLocationAuthorizationStatusChangeHandler(), which is invoked in response to a change in authorisation status. So on iOS, the requestLocationAuthorization() success callback is invoked on successfully making the request, not in response to the user's choice in the dialog.

In the short term, I'll update the docs. In the longer term, I'll see if I can do away with registerLocationAuthorizationStatusChangeHandler() on iOS and simply have the success function of requestLocationAuthorization() be called after the user has made their choice (same as Android).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants