Commit eb7f0cb5 authored by Steven杜宇's avatar Steven杜宇

// 通知

parent 76000ba2
......@@ -30,6 +30,22 @@ class YHMyNotifySettingVC: YHBaseViewController {
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
checkNotificationAuthorizationStatus {
[weak self] granted in
guard let self = self else { return }
for item in items {
if item.type == .notify {
item.enableStatus = granted
}
}
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
func setupUI() {
gk_navTitle = "通知设置".local
view.backgroundColor = .white
......@@ -40,6 +56,31 @@ class YHMyNotifySettingVC: YHBaseViewController {
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
}
func checkNotificationAuthorizationStatus(_ callBack:((Bool)->())?) {
UNUserNotificationCenter.current().getNotificationSettings { settings in
var enableStatus = false
switch settings.authorizationStatus {
case .authorized:
print("通知已授权")
enableStatus = true
case .denied:
print("通知被拒绝")
enableStatus = false
case .notDetermined:
print("通知权限尚未确定")
enableStatus = false
case .provisional:
print("通知以临时方式授权")
enableStatus = false
case .ephemeral:
enableStatus = false
@unknown default:
break
}
callBack?(enableStatus)
}
}
}
extension YHMyNotifySettingVC: UITableViewDelegate, UITableViewDataSource {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment