PromiseKit / CoreLocation

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

Can't ask for "always" permission when asked for "whenInUse" firstly #4

Closed paweljankowski closed 6 years ago

paweljankowski commented 6 years ago

When I'm asking for whenInUse location permission then when I'm asking for always the promise is fulfilled with current status (whenInUse).

mxcl commented 6 years ago

Yeah, will need updating for iOS 11 I guess. PR welcome.

paweljankowski commented 6 years ago

@mxcl https://github.com/PromiseKit/CoreLocation/pull/5 :-)

mxcl commented 6 years ago

I could use some more detailed instructions on how to reproduce this and what happens.

bruno-rocha-movile commented 6 years ago

This method works consistently for me:

If you do this, the promotion dialog will show up but quickly close itself. This is because the promise will prematurely succeed due to the previously accepted whenInUse permission. The dialog closes because the location manager gets released right after the location is retrieved (which is correct, but in this case we want to wait for the user to act upon the dialog)

So to fix this, we have to identify if this is a promotion request and prevent releasing the manager before the dialog is closed. Since retaining the manager for eternity would probably be bad, this may require some thought

mxcl commented 6 years ago

Please review above PR

mxcl commented 6 years ago

Pretty please review the above PR. Thanks!