PingAMPushResponder

public final class PingAMPushResponder : @unchecked Sendable
extension PingAMPushResponder: PingAMPushResponderType

Handles PingAM-specific network operations such as registration and authentication responses.

The responder encapsulates JWT generation, challenge response calculation, and request payload creation for PingAM endpoints. Networking operations are executed using the supplied HttpClient, while logging is delegated to the provided Logger instance.

Initialization

  • Creates a new PingAM responder.

    Declaration

    Swift

    public init(httpClient: any HttpClientProtocol, logger: Logger? = LogManager.logger)

    Parameters

    httpClient

    The HTTP client responsible for executing network requests.

    logger

    Optional logger used for diagnostic output. Defaults to the global logger.

Registration

  • Registers a push credential with PingAM.

    Throws

    PushError when required parameters are missing, the request fails, or the response is unsuccessful.

    Declaration

    Swift

    @discardableResult
    public func register(
        credential: PushCredential,
        params: [String: Any]
    ) async throws -> Bool

    Parameters

    credential

    The credential that should be enrolled with PingAM.

    params

    Additional registration parameters including challenge, messageId, and device metadata.

    Return Value

    true when the registration request succeeds (HTTP 2xx).

Authentication

  • Sends an authentication decision (approve or deny) to PingAM.

    Throws

    PushError when required data is missing or the network request fails.

    Declaration

    Swift

    @discardableResult
    public func sendAuthenticationResponse(
        credential: PushCredential,
        notification: PushNotification,
        approve: Bool,
        numbersChallengeResponse: String? = nil
    ) async throws -> Bool

    Parameters

    credential

    The credential associated with the notification.

    notification

    The notification being responded to.

    approve

    true to approve, false to deny.

    numbersChallengeResponse

    Optional user-entered response for number-matching challenges.

    Return Value

    true when the request succeeds (HTTP 2xx).

Device Token Updates

  • Updates the device token registered with PingAM.

    Throws

    PushError when the token is invalid or the request fails.

    Declaration

    Swift

    @discardableResult
    public func updateDeviceToken(
        credential: PushCredential,
        deviceToken: String,
        deviceName: String? = nil
    ) async throws -> Bool

    Parameters

    credential

    The credential whose device token should be refreshed.

    deviceToken

    The APNs token to register.

    deviceName

    Optional device name; defaults to a platform-specific value when nil.

    Return Value

    true when the request succeeds (HTTP 2xx).