我知道这不行,因为它completion handler是在一个background Thread但是
我应该在哪里派遣主队列或我还需要做什么?
这是代码:
static func isNotificationNotDetermined() -> Bool{
var isNotDetermined = false
UNUserNotificationCenter.current().getNotificationSettings { (notificationSettings) in
switch notificationSettings.authorizationStatus {
case .notDetermined:
isNotDetermined = true
case .authorized:
isNotDetermined = false
case .denied:
isNotDetermined = false
}
}
return isNotDetermined
}
Run Code Online (Sandbox Code Playgroud)