delba / Permission

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

Wrong Location Permission behavior #124

Open vadimue opened 6 years ago

vadimue commented 6 years ago

I am developing an app, which uses location always. So I request Location permission with status "Always" on viewDidLoad() of WelcomeViewController. Steps of this flow:

  1. App show alert with three buttons "Only when using the app", "Always Allow", "Don't Allow".
  2. User chooses "Only when using the app".
  3. User reopen app and did not see any notification
  4. User reopens app again (and all next times) and sees the denied notification.

The problem is user don't see notification second time. I read a source code and find out the line of cause such behavior: On second time UserDefaults.standard.requestedLocationAlwaysWithWhenInUse still false, so we have wrong status of location permission that's why app requests permission again instead of showing denied alert. And in this second requesting UserDefaults.standard.requestedLocationAlwaysWithWhenInUse became true, so on third time we have correct status.

Frankly, I don't know how to fix this problem by the clean way, can you have any suggestion?

vadimue commented 6 years ago

@sunshinejr Hi, I guess maybe you can know about this flow? Why we need return UserDefaults.standard.requestedLocationAlwaysWithWhenInUse ? .denied : .notDetermined in case of authorizedWhenInUse status, and don't return simply .denied? I think it can resolve my problem.