Hi Everybody,
I am trying to implement a function that returns the current UNAuthorizationStatus for use in a View to show a button or not. The function below doesn´t work because the closure is executed after the return - is there any simple way to achieve this?
func getStatus() -> UNAuthorizationStatus {
var result: UNAuthorizationStatus = .notDetermined
UNUserNotificationCenter.current().getNotificationSettings(
completionHandler: { (settings) in
result = settings.authorizationStatus
print("result in closure = \(result.rawValue)")
}
)
print("result at return = \(result.rawValue)")
return result
}
Sorry, if this is a bit of a rookie question but I don´t seem to be able to figure this out.
Thanks
Florian