Pigeon. ADM. Notification
(Pigeon v2.1.0)
View Source
Defines Amazon ADM notification struct and convenience constructor functions.
Summary
Functions
Creates ADM.Notification struct with device registration ID and optional data payload.
Updates "data" key on push payload and calculates md5 hash.
Types
@type error_response() ::
:access_token_expired
| :invalid_registration_id
| :invalid_data
| :invalid_consolidation_key
| :invalid_expiration
| :invalid_checksum
| :invalid_type
| :max_rate_exceeded
| :message_too_large
| :unregistered
| :unknown_error
ADM error responses
@type response() :: error_response() | nil | :not_connected | :not_started | :success | :timeout
ADM push response
error_response/0- Push attempted but server responded with error- nil - Push has not been sent yet
:not_connected- Dispatcher had no live connection to ADM, or the access token refresh failed. Push was not sent:not_started- Dispatcher is not running. Push was not sent:success- Push was successfully sent:timeout- Push was sent but the connection dropped before ADM responded. Delivery is unknown
@type t() :: %Pigeon.ADM.Notification{ __meta__: Pigeon.Metadata.t(), consolidation_key: String.t(), expires_after: integer(), md5: binary(), payload: %{}, registration_id: String.t(), response: response(), updated_registration_id: String.t() }
ADM notification
Examples
%Pigeon.ADM.Notification{
consolidation_key: nil,
expires_after: 604_800,
md5: "qzF+HgArKZjJrpfcTbiFxg==",
payload: %{
"data" => %{"message" => "your message"}
},
registration_id: "reg ID",
response: nil, # Set on push response
updated_registration_id: nil
}
Functions
Creates ADM.Notification struct with device registration ID and optional data payload.
Examples
iex> Pigeon.ADM.Notification.new("reg ID")
%Pigeon.ADM.Notification{
consolidation_key: nil,
md5: "1B2M2Y8AsgTpgAmY7PhCfg==",
payload: %{"data" => %{}},
registration_id: "reg ID",
updated_registration_id: nil
}
iex> Pigeon.ADM.Notification.new("reg ID", %{"message" => "your message"})
%Pigeon.ADM.Notification{
consolidation_key: nil,
md5: "qzF+HgArKZjJrpfcTbiFxg==",
payload: %{
"data" => %{"message" => "your message"}
},
registration_id: "reg ID",
updated_registration_id: nil
}
iex> Pigeon.ADM.Notification.new("reg ID", "not a map")
%Pigeon.ADM.Notification{
consolidation_key: nil,
md5: "1B2M2Y8AsgTpgAmY7PhCfg==",
payload: %{"data" => %{}},
registration_id: "reg ID",
updated_registration_id: nil
}
Updates "data" key on push payload and calculates md5 hash.
Examples
iex> n = %Pigeon.ADM.Notification{}
iex> Pigeon.ADM.Notification.put_data(n, %{"message" => "your message"})
%Pigeon.ADM.Notification{
consolidation_key: nil,
md5: "qzF+HgArKZjJrpfcTbiFxg==",
payload: %{
"data" => %{"message" => "your message"}
},
registration_id: nil,
updated_registration_id: nil
}