Skip to content

Commit

Permalink
Merge pull request #112 from UbiqueInnovation/feature/async-push-perm…
Browse files Browse the repository at this point in the history
…issions-query

Fixes push permissions query
  • Loading branch information
bastianmorath authored Nov 12, 2024
2 parents 0d137a3 + 735d6f2 commit 031e33d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Sources/UBPush/UBPushManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,21 @@ open class UBPushManager: NSObject {
}

/// Querys the current push permissions from the system
public func queryPushPermissions(callback: @escaping (Bool) -> Void) {
UNUserNotificationCenter.current().getNotificationSettings { settings in
public func queryPushPermissions(callback: @Sendable @escaping (Bool) -> Void) {
UNUserNotificationCenter.current().getNotificationSettings { @Sendable settings in
let isEnabled = settings.alertSetting == .enabled
DispatchQueue.main.async {
callback(isEnabled)
}
}
}

/// Querys the current push permissions from the system
public func queryPushPermissions() async -> Bool {
let settings = await UNUserNotificationCenter.current().notificationSettings()
let isEnabled = settings.alertSetting == .enabled
return isEnabled
}

// MARK: - Push Registration

Expand Down

0 comments on commit 031e33d

Please sign in to comment.