authorizationStatus is not updating on permission changed.
Alternate:
This is what I came up after spending hours in trying different solutions.
You can simply add below requestAuthorization in applicationWillEnterForeground (if you have logged in mechanism please call when user logged in), this will initiate permission popover if permission required otherwise it will not do anything.
Task {
do {
try await AuthorizationCenter.shared.requestAuthorization(for: .individual)
} catch {
print(error)
}
}
And to observe the permission status
AuthorizationCenter.shared.$authorizationStatus.sink { authorizationStatus in
print("authorizationStatus updated")
}
.store(in: &cancellables)
Though this observer will get called on every app launch, you can update your views or block apps again depending on your needs.
Topic:
App & System Services
SubTopic:
General
Tags: