delba / Permission

A unified API to ask for permissions on iOS
MIT License
2.91k stars 323 forks source link

Location callback is executed before decision was made #28

Closed Eckelf closed 8 years ago

Eckelf commented 8 years ago

The location callback is executed too early when the underlying LocationManager has not been initialized before. When a CLLocationManager is first initialized it calls its locationManager(_:didChangeAuthorizationStatus:) delegate method regardless of any change (asynchronously as far as I can tell).

Example:

  1. Initial permission status is NotDetermined, Permission has not been used before
  2. Permission.request(Callback) is executed
  3. Callback has result NotDetermined before user even made a choice due to initialization of internal LocationManager. The actual decision is subsequently ignored.

I guess an easy fix would be to keep a reference to the current authorization status and compare it to the one given in locationManager(_:didChangeAuthorizationStatus:) to make sure that the value actually changed.

delba commented 8 years ago

Hi @Eckelf , thanks for the issue!

This problem should be fixed on master. Can you please confirm it ? If so, I'd be able to ship a new release later today :)

Eckelf commented 8 years ago

Hi @delba,

ahh yes that works. A new release would be nice.

Thank you very much!

delba commented 8 years ago

Ahhaha good to hear!!

I'll ping you when it's done, thanks!

delba commented 8 years ago

@Eckelf The 1.4.1 version has been released

dimohamdy commented 8 years ago

i have this issue how i can solve it locationManager(_:didChangeAuthorizationStatus:) not called after request location