使用临时通知权限

This commit is contained in:
Fin 2025-05-15 15:22:30 +08:00
parent dae1ce7bea
commit 204bed637f
2 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ class Client: NSObject {
func registerForRemoteNotifications() { func registerForRemoteNotifications() {
let center = UNUserNotificationCenter.current() let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge, .criticalAlert], completionHandler: { (_ granted: Bool, _: Error?) in center.requestAuthorization(options: [.alert, .sound, .badge, .criticalAlert, .provisional], completionHandler: { (_ granted: Bool, _: Error?) in
if granted { if granted {
dispatch_sync_safely_main_queue { dispatch_sync_safely_main_queue {
UIApplication.shared.registerForRemoteNotifications() UIApplication.shared.registerForRemoteNotifications()

View File

@ -87,7 +87,7 @@ class HomeViewController: BaseViewController<HomeViewModel> {
let startRequestAuthorization: () -> Observable<Bool> = { let startRequestAuthorization: () -> Observable<Bool> = {
Single<Bool>.create { single -> Disposable in Single<Bool>.create { single -> Disposable in
let center = UNUserNotificationCenter.current() let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge, .criticalAlert], completionHandler: { (_ granted: Bool, _: Error?) in center.requestAuthorization(options: [.alert, .sound, .badge, .criticalAlert, .provisional], completionHandler: { (_ granted: Bool, _: Error?) in
single(.success(granted)) single(.success(granted))
}) })
return Disposables.create() return Disposables.create()