PushClient
public final class PushClient : @unchecked Sendable
Public-facing client that orchestrates Push MFA operations.
The client exposes high-level APIs for credential management, notification
processing, and response handling while delegating business logic to the
internal PushService. Clients should create instances using the DSL-style
factory methods which encapsulate configuration defaults and dependency setup.
-
createClient(configure:Asynchronous) Creates a
PushClientusing a DSL-style configuration closure.Throws
PushError.initializationFailedwhen dependency setup fails.Declaration
Swift
public static func createClient( configure: (PushConfiguration) -> Void = { _ in } ) async throws -> PushClientParameters
configureClosure that mutates a fresh
PushConfiguration.Return Value
A fully initialized
PushClient. -
createClient(configuration:Asynchronous) Creates a
PushClientfrom an existingPushConfigurationinstance.Throws
PushError.initializationFailedwhen dependency setup fails.Declaration
Swift
public static func createClient( configuration: PushConfiguration ) async throws -> PushClientParameters
configurationPre-constructed configuration object.
Return Value
A fully initialized
PushClient.
-
addCredentialFromUri(_:Asynchronous) Registers a Push credential from a
pushauth://URI (typically obtained via QR code).Throws
PushErrorwhen parsing, policy evaluation, registration, or storage fails.Declaration
Swift
public func addCredentialFromUri(_ uri: String) async throws -> PushCredentialParameters
uriEnrollment URI containing credential details and registration parameters.
Return Value
The stored
PushCredentialinstance. -
saveCredential(_:Asynchronous) Persists a Push credential that was created or fetched externally.
Throws
PushError.storageFailurewhen persistence fails.Declaration
Swift
public func saveCredential(_ credential: PushCredential) async throws -> PushCredentialParameters
credentialThe credential to store.
Return Value
The stored credential (potentially updated by policy evaluation).
-
getCredentials()AsynchronousRetrieves all stored Push credentials.
Throws
PushError.storageFailurewhen storage access fails.Declaration
Swift
public func getCredentials() async throws -> [PushCredential]Return Value
Array of credentials currently known to the client.
-
getCredential(credentialId:Asynchronous) Retrieves a single Push credential by identifier.
Throws
PushError.storageFailurewhen storage access fails.Declaration
Swift
public func getCredential(credentialId: String) async throws -> PushCredential?Parameters
credentialIdIdentifier of the credential to fetch.
Return Value
The credential when found, otherwise
nil. -
deleteCredential(credentialId:Asynchronous) Deletes a Push credential and any associated cached state.
Throws
PushError.storageFailurewhen storage access fails.Declaration
Swift
public func deleteCredential(credentialId: String) async throws -> BoolParameters
credentialIdIdentifier of the credential to remove.
Return Value
truewhen a credential was removed,falsewhen it did not exist.
-
setDeviceToken(_:AsynchronouscredentialId: ) Updates the APNs device token used for Push notifications.
Throws
PushErrorwhen validation, storage, or handler operations fail.Declaration
Swift
public func setDeviceToken( _ deviceToken: String, credentialId: String? = nil ) async throws -> BoolParameters
deviceTokenRaw APNs device token string.
credentialIdOptional credential identifier to scope the update. When
nil, all registered credentials are updated.Return Value
truewhen the handler reports success for all updates (or the token is unchanged). -
getDeviceToken()AsynchronousRetrieves the currently stored APNs device token, if available.
Throws
PushError.storageFailurewhen storage access fails.Declaration
Swift
public func getDeviceToken() async throws -> String?Return Value
The device token string or
nilwhen no token has been stored.
-
processNotification(messageData:Asynchronous) Processes a push notification represented as a dictionary payload (e.g. APNs
userInfo).Throws
PushErrorwhen parsing or persistence fails.Declaration
Swift
public func processNotification(messageData: [String : Any]) async throws -> PushNotification?Parameters
messageDataRaw notification payload.
Return Value
The stored
PushNotification(ornilwhen the payload is unsupported). -
processNotification(message:Asynchronous) Processes a push notification represented as a string payload (typically JWT).
Throws
PushErrorwhen parsing or persistence fails.Declaration
Swift
public func processNotification(message: String) async throws -> PushNotification?Parameters
messageEncoded notification payload.
Return Value
The stored
PushNotification(ornilwhen the payload is unsupported). -
processNotification(userInfo:Asynchronous) Processes a push notification using a
UNNotification-styleuserInfodictionary.This method automatically extracts APNs custom data from the nested
apsdictionary format:aps["data"]→message(JWT)aps["messageId"]→messageId
Throws
PushErrorwhen parsing or persistence fails.Declaration
Swift
public func processNotification(userInfo: [AnyHashable : Any]) async throws -> PushNotification?Parameters
userInfoNotification payload in
[AnyHashable: Any]form (APNsuserInfo).Return Value
The stored
PushNotification(ornilwhen unsupported).
-
approveNotification(_:Asynchronous) Approves a pending notification identified by
notificationId.Throws
PushErrorwhen the client is not initialized, the notification cannot be found, or handler/storage operations fail.Declaration
Swift
public func approveNotification(_ notificationId: String) async throws -> BoolParameters
notificationIdIdentifier of the notification to approve.
Return Value
truewhen the approval succeeds,falsewhen the notification is no longer pending or the handler reports failure. -
approveChallengeNotification(_:AsynchronouschallengeResponse: ) Approves a challenge-based notification by supplying the challenge response.
Throws
PushError.invalidParameterValuewhen the response is empty, orPushErrorsurfaced by the underlying service.Declaration
Swift
public func approveChallengeNotification( _ notificationId: String, challengeResponse: String ) async throws -> BoolParameters
notificationIdIdentifier of the notification to approve.
challengeResponseUser-provided response required for number-matching flows.
Return Value
truewhen the approval succeeds. -
Approves a biometric notification by indicating the authentication method used.
Declaration
Swift
public func approveBiometricNotification( _ notificationId: String, authenticationMethod: String ) async throws -> BoolParameters
notificationIdIdentifier of the notification to approve.
authenticationMethodMethod used to authenticate the user (for example, “face” or “fingerprint”).
Return Value
truewhen the approval succeeds. -
denyNotification(_:Asynchronous) Denies a pending notification.
Throws
PushErrorsurfaced from the underlying service operations.Declaration
Swift
public func denyNotification(_ notificationId: String) async throws -> BoolParameters
notificationIdIdentifier of the notification to deny.
Return Value
truewhen the denial succeeds.
-
getPendingNotifications()AsynchronousRetrieves all pending notifications awaiting user action.
Throws
PushErrorsurfaced from storage operations.Declaration
Swift
public func getPendingNotifications() async throws -> [PushNotification]Return Value
Array of pending notifications.
-
getAllNotifications()AsynchronousRetrieves all stored notifications, regardless of status.
Throws
PushErrorsurfaced from storage operations.Declaration
Swift
public func getAllNotifications() async throws -> [PushNotification]Return Value
Array of notifications.
-
getNotification(notificationId:Asynchronous) Retrieves a specific notification by identifier.
Throws
PushErrorsurfaced from storage operations.Declaration
Swift
public func getNotification(notificationId: String) async throws -> PushNotification?Parameters
notificationIdIdentifier of the notification to fetch.
Return Value
The notification when found, otherwise
nil. -
cleanupNotifications(credentialId:Asynchronous) Runs notification cleanup according to the configured strategy.
Throws
PushErrorwhen storage operations fail.Declaration
Swift
public func cleanupNotifications(credentialId: String? = nil) async throws -> IntParameters
credentialIdOptional credential identifier to scope the cleanup.
Return Value
The number of notifications removed during cleanup.
-
close()AsynchronousClears cached state and marks the client as uninitialized.
Declaration
Swift
public func close() async
View on GitHub