Is it possible to check permission status while app is closed on iOS? My use case is I want to send out a notification at periodic intervals if the app does not have the “Always” location turned on.
Is it possible to check permission status while app is closed on iOS? My use case is I want to send out a notification at periodic intervals if the app does not have the “Always” location turned on.
2
Answers
Follow this Using Background Tasks to Update Your App.
You can do something when app is wakened by system to run in the background.
But if the user explicitly denies the
AlwaysAuthorization
permission, you should not ask the user periodically. It is very bad UX.AppleStore reviewers may reject your app also.
I think you should find a suitable way to ask the user or only show a warning popup when the user opens app and use the function that requires
AlwaysAuthorization
. Or ask the user to grant this permission on the first app runs.Changes in authorization state are typically detected using the locationManagerDidChangeAuthorization event in CLLocationManagerDelegate. However, when the app is closed, the user’s status cannot be detected. You can use this method to detect the change of authorization status when the user is using the app.
For more details, you can refer to the following docs:
locationManagerDidChangeAuthorization