PushStorage
public protocol PushStorage : Sendable
Protocol for Push-specific storage operations. Extends the base storage capabilities with Push-specific functionality.
Implementations of this protocol must be thread-safe and handle concurrent access properly.
-
storePushCredential(_:Asynchronous) Store a push credential.
Throws
PushStorageError.storageFailureif the credential cannot be stored.Throws
PushStorageError.duplicateCredentialif a credential with the same ID already exists.Declaration
Swift
func storePushCredential(_ credential: PushCredential) async throwsParameters
credentialThe Push credential to be stored.
-
getAllPushCredentials()AsynchronousRetrieve all stored push credentials.
Throws
PushStorageError.storageFailureif the credentials cannot be retrieved.Declaration
Swift
func getAllPushCredentials() async throws -> [PushCredential]Return Value
A list of all Push credentials.
-
retrievePushCredential(credentialId:Asynchronous) Retrieve a specific push credential by ID.
Throws
PushStorageError.storageFailureif the credential cannot be retrieved.Declaration
Swift
func retrievePushCredential(credentialId: String) async throws -> PushCredential?Parameters
credentialIdThe ID of the credential to retrieve.
Return Value
The Push credential, or nil if not found.
-
removePushCredential(credentialId:Asynchronous) Remove a push credential by its ID.
Throws
PushStorageError.storageFailureif the credential cannot be removed.Declaration
Swift
func removePushCredential(credentialId: String) async throws -> BoolParameters
credentialIdThe ID of the credential to remove.
Return Value
true if the credential was successfully removed, false if it didn’t exist.
-
clearPushCredentials()AsynchronousClear all Push credentials from the storage.
Throws
PushStorageError.storageFailureif the credentials cannot be cleared.Declaration
Swift
func clearPushCredentials() async throws -
getCredentialByIssuerAndAccount(issuer:AsynchronousaccountName: ) Retrieve a push credential by issuer and account name. Used for duplicate detection during credential registration.
Throws
PushStorageError.storageFailureif the credential cannot be retrieved.Declaration
Swift
func getCredentialByIssuerAndAccount(issuer: String, accountName: String) async throws -> PushCredential?Parameters
issuerThe issuer of the credential.
accountNameThe account name of the credential.
Return Value
The Push credential if found, nil otherwise.
-
storePushNotification(_:Asynchronous) Store a push notification.
Throws
PushStorageError.storageFailureif the notification cannot be stored.Declaration
Swift
func storePushNotification(_ notification: PushNotification) async throwsParameters
notificationThe Push notification to be stored.
-
updatePushNotification(_:Asynchronous) Update a push notification.
Throws
PushStorageError.storageFailureif the notification cannot be updated.Declaration
Swift
func updatePushNotification(_ notification: PushNotification) async throwsParameters
notificationThe Push notification to update.
-
getAllPushNotifications()AsynchronousRetrieve all stored push notifications.
Throws
PushStorageError.storageFailureif the notifications cannot be retrieved.Declaration
Swift
func getAllPushNotifications() async throws -> [PushNotification]Return Value
A list of all Push notifications.
-
getPendingPushNotifications()AsynchronousRetrieve all pending push notifications.
Throws
PushStorageError.storageFailureif the notifications cannot be retrieved.Declaration
Swift
func getPendingPushNotifications() async throws -> [PushNotification]Return Value
A list of pending Push notifications.
-
retrievePushNotification(notificationId:Asynchronous) Retrieve a specific push notification by ID.
Throws
PushStorageError.storageFailureif the notification cannot be retrieved.Declaration
Swift
func retrievePushNotification(notificationId: String) async throws -> PushNotification?Parameters
notificationIdThe ID of the notification to retrieve.
Return Value
The Push notification, or nil if not found.
-
getNotificationByMessageId(messageId:Asynchronous) Retrieve a push notification by message ID.
Throws
PushStorageError.storageFailureif the notification cannot be retrieved.Declaration
Swift
func getNotificationByMessageId(messageId: String) async throws -> PushNotification?Parameters
messageIdThe message ID of the notification to retrieve.
Return Value
The Push notification, or nil if not found.
-
removePushNotification(notificationId:Asynchronous) Remove a push notification by its ID.
Throws
PushStorageError.storageFailureif the notification cannot be removed.Declaration
Swift
func removePushNotification(notificationId: String) async throws -> BoolParameters
notificationIdThe ID of the notification to remove.
Return Value
true if the notification was successfully removed, false if it didn’t exist.
-
removePushNotificationsForCredential(credentialId:Asynchronous) Remove all push notifications associated with a credential.
Throws
PushStorageError.storageFailureif the notifications cannot be removed.Declaration
Swift
func removePushNotificationsForCredential(credentialId: String) async throws -> IntParameters
credentialIdThe ID of the credential.
Return Value
The number of notifications removed.
-
clearPushNotifications()AsynchronousClear all Push notifications from the storage.
Throws
PushStorageError.storageFailureif the notifications cannot be cleared.Declaration
Swift
func clearPushNotifications() async throws
-
storePushDeviceToken(_:Asynchronous) Store a push device token.
Throws
PushStorageError.storageFailureif the token cannot be stored.Declaration
Swift
func storePushDeviceToken(_ token: PushDeviceToken) async throwsParameters
tokenThe Push device token to be stored.
-
getCurrentPushDeviceToken()AsynchronousRetrieve the current push device token.
Throws
PushStorageError.storageFailureif the token cannot be retrieved.Declaration
Swift
func getCurrentPushDeviceToken() async throws -> PushDeviceToken?Return Value
The current Push device token, or nil if not found.
-
clearPushDeviceTokens()AsynchronousClear all Push device tokens from the storage.
Throws
PushStorageError.storageFailureif the tokens cannot be cleared.Declaration
Swift
func clearPushDeviceTokens() async throws
-
countPushNotifications(credentialId:Asynchronous) Count the number of push notifications.
Throws
PushStorageError.storageFailureif the count cannot be retrieved.Declaration
Swift
func countPushNotifications(credentialId: String?) async throws -> IntParameters
credentialIdOptional ID of a specific credential to count notifications for.
Return Value
The count of push notifications.
-
getOldestPushNotifications(limit:AsynchronouscredentialId: ) Retrieve the oldest push notifications.
Throws
PushStorageError.storageFailureif the notifications cannot be retrieved.Declaration
Swift
func getOldestPushNotifications(limit: Int, credentialId: String?) async throws -> [PushNotification]Parameters
limitThe maximum number of notifications to retrieve.
credentialIdOptional ID of a specific credential to retrieve notifications for.
Return Value
A list of the oldest push notifications.
-
Purge push notifications by age.
Throws
PushStorageError.storageFailureif the notifications cannot be purged.Declaration
Swift
func purgePushNotificationsByAge(maxAgeDays: Int, credentialId: String?) async throws -> IntParameters
maxAgeDaysThe maximum age in days for notifications to keep.
credentialIdOptional ID of a specific credential to purge notifications for.
Return Value
The number of notifications removed.
-
Purge push notifications by count (removes oldest notifications when count exceeds the limit).
Throws
PushStorageError.storageFailureif the notifications cannot be purged.Declaration
Swift
func purgePushNotificationsByCount(maxCount: Int, credentialId: String?) async throws -> IntParameters
maxCountThe maximum number of notifications to keep.
credentialIdOptional ID of a specific credential to purge notifications for.
Return Value
The number of notifications removed.
View on GitHub