A struct representing the response from a push notification request.
Fields
:provider- The provider used (:apnsor:fcm):status- The result status (see below):id- Provider-specific message ID (if available):reason- Error reason string (if failed):raw- Raw response body (for debugging)
Status Values
:sent- Message was successfully sent:invalid_token- Device token is invalid or expired:expired_token- Device token has expired:unregistered- Device is no longer registered:payload_too_large- Payload exceeds size limit:rate_limited- Too many requests, try again later:server_error- Provider server error:connection_error- Network/connection failure:unknown_error- Unrecognized error
Summary
Functions
Maps an APNS error reason to a status atom.
Creates an error response.
Creates an error response with raw data.
Creates an error response with raw data and retry_after value.
Maps an FCM error code to a status atom.
Returns true if the error is retryable.
Returns true if the token should be removed from the database.
Creates a successful response.
Returns true if the response indicates success.
Types
@type status() ::
:sent
| :invalid_token
| :expired_token
| :unregistered
| :payload_too_large
| :rate_limited
| :server_error
| :connection_error
| :unknown_error
@type t() :: %PushX.Response{ id: String.t() | nil, provider: :apns | :fcm, raw: any(), reason: String.t() | nil, retry_after: non_neg_integer() | nil, status: status() }
Functions
Maps an APNS error reason to a status atom.
Creates an error response.
@spec error( provider :: :apns | :fcm, status :: status(), reason :: String.t() | nil, raw :: any() ) :: t()
Creates an error response with raw data.
@spec error( provider :: :apns | :fcm, status :: status(), reason :: String.t() | nil, raw :: any(), retry_after :: non_neg_integer() | nil ) :: t()
Creates an error response with raw data and retry_after value.
Maps an FCM error code to a status atom.
See: https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode
Returns true if the error is retryable.
Retryable errors:
:connection_error- Network/connection failure:rate_limited- Too many requests (with backoff):server_error- Provider server error (5xx)
Returns true if the token should be removed from the database.
Creates a successful response.
Returns true if the response indicates success.