Permission
Permission copied to clipboard
Wrong Location Permission behavior
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:
- App show alert with three buttons "Only when using the app", "Always Allow", "Don't Allow".
- User chooses "Only when using the app".
- User reopen app and did not see any notification
- 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?
@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.