Skip to content
Merged

push #157

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions Sources/NextcloudKit/NextcloudKit+PushNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Data>?,
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(),
Expand All @@ -76,6 +116,34 @@ public extension NextcloudKit {
}
}

func unsubscribingPushNotificationAsync(
serverUrl: String,
account: String,
options: NKRequestOptions = NKRequestOptions()
) async -> (
account: String,
responseData: AFDataResponse<Data>?,
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,
Expand Down Expand Up @@ -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<Data>?,
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,
Expand Down Expand Up @@ -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<Data>?,
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))
}
)
}
}
}
Loading