class SystemNotificationSetting {
static func checkPushNotificationAuthorization(_ block: @escaping (Bool) -> Void) {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().getNotificationSettings { settings in
let result = {
switch settings.authorizationStatus {
case .authorized:
return true
default:
return false
}
}()
DispatchQueue.main.async {
block(result)
}
}
} else {
let setting = UIApplication.shared.currentUserNotificationSettings
let bl = setting?.types.isEmpty ?? true
block(!bl)
}
}
//跳转app设置
static func openAppSysSetting() {
guard let url = URL(string: UIApplication.openSettingsURLString),
UIApplication.shared.canOpenURL(url) else {
Toast.show("无法打开系统设置")
return
}
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
}
iOS开发swift判断app推送通知权限
于 2023-09-20 08:51:41 首次发布