|
...
|
...
|
@@ -54,6 +54,35 @@ final class PlatformHostApiImpl: PlatformHostApi { |
|
|
|
return false
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
func requestNotificationAuth(completion: @escaping (Result<Bool, any Error>) -> Void) {
|
|
|
|
Task {
|
|
|
|
let center = UNUserNotificationCenter.current()
|
|
|
|
let settings = await center.notificationSettings()
|
|
|
|
|
|
|
|
switch settings.authorizationStatus {
|
|
|
|
case .authorized, .provisional, .ephemeral:
|
|
|
|
completion(.success(true))
|
|
|
|
case .notDetermined:
|
|
|
|
do {
|
|
|
|
let granted = try await center.requestAuthorization(options: [.alert, .sound, .badge])
|
|
|
|
if granted {
|
|
|
|
await MainActor.run {
|
|
|
|
UIApplication.shared.registerForRemoteNotifications()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
completion(.success(granted))
|
|
|
|
} catch {
|
|
|
|
completion(.failure(error))
|
|
|
|
}
|
|
|
|
case .denied:
|
|
|
|
completion(.success(false))
|
|
|
|
@unknown default:
|
|
|
|
completion(.success(false))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func nativeHandleUrl(urlString: String) throws -> Bool {
|
|
|
|
if let url = URL(string: urlString){
|
...
|
...
|
|