diff --git a/Sources/NextcloudKit/NextcloudKit+PushNotification.swift b/Sources/NextcloudKit/NextcloudKit+PushNotification.swift index b6b1b2d3..5435b31a 100644 --- a/Sources/NextcloudKit/NextcloudKit+PushNotification.swift +++ b/Sources/NextcloudKit/NextcloudKit+PushNotification.swift @@ -50,6 +50,46 @@ public extension NextcloudKit { } } + func subscribingPushNotificationAsync( + serverUrl: String, + pushTokenHash: String, + devicePublicKey: String, + proxyServerUrl: String, + account: String, + options: NKRequestOptions = NKRequestOptions() + ) async -> ( + account: String, + deviceIdentifier: String?, + signature: String?, + publicKey: String?, + responseData: AFDataResponse?, + error: NKError + ) { + await withCheckedContinuation { continuation in + subscribingPushNotification( + serverUrl: serverUrl, + pushTokenHash: pushTokenHash, + devicePublicKey: devicePublicKey, + proxyServerUrl: proxyServerUrl, + account: account, + options: options, + taskHandler: { _ in }, + completion: { account, deviceIdentifier, signature, publicKey, responseData, error in + continuation.resume( + returning: ( + account, + deviceIdentifier, + signature, + publicKey, + responseData, + error + ) + ) + } + ) + } + } + func unsubscribingPushNotification(serverUrl: String, account: String, options: NKRequestOptions = NKRequestOptions(), @@ -76,6 +116,34 @@ public extension NextcloudKit { } } + func unsubscribingPushNotificationAsync( + serverUrl: String, + account: String, + options: NKRequestOptions = NKRequestOptions() + ) async -> ( + account: String, + responseData: AFDataResponse?, + error: NKError + ) { + await withCheckedContinuation { continuation in + unsubscribingPushNotification( + serverUrl: serverUrl, + account: account, + options: options, + taskHandler: { _ in }, + completion: { account, responseData, error in + continuation.resume( + returning: ( + account, + responseData, + error + ) + ) + } + ) + } + } + func subscribingPushProxy(proxyServerUrl: String, pushToken: String, deviceIdentifier: String, @@ -113,6 +181,33 @@ public extension NextcloudKit { } } + func subscribingPushProxyAsync( + proxyServerUrl: String, + pushToken: String, + deviceIdentifier: String, + signature: String, + publicKey: String, + account: String, + options: NKRequestOptions = NKRequestOptions()) async -> (account: String, + responseData: AFDataResponse?, + error: NKError) { + await withCheckedContinuation { continuation in + subscribingPushProxy( + proxyServerUrl: proxyServerUrl, + pushToken: pushToken, + deviceIdentifier: deviceIdentifier, + signature: signature, + publicKey: publicKey, + account: account, + options: options, + taskHandler: { _ in }, + completion: { account, responseData, error in + continuation.resume(returning: (account, responseData, error)) + } + ) + } + } + func unsubscribingPushProxy(proxyServerUrl: String, deviceIdentifier: String, signature: String, @@ -147,4 +242,30 @@ public extension NextcloudKit { } } } + + func unsubscribingPushProxyAsync( + proxyServerUrl: String, + deviceIdentifier: String, + signature: String, + publicKey: String, + account: String, + options: NKRequestOptions = NKRequestOptions() + ) async -> (account: String, + responseData: AFDataResponse?, + error: NKError) { + await withCheckedContinuation { continuation in + unsubscribingPushProxy( + proxyServerUrl: proxyServerUrl, + deviceIdentifier: deviceIdentifier, + signature: signature, + publicKey: publicKey, + account: account, + options: options, + taskHandler: { _ in }, + completion: { account, responseData, error in + continuation.resume(returning: (account, responseData, error)) + } + ) + } + } }