Pigeon.ADM.Notification (Pigeon v2.0.0-rc.0) View Source
Defines Amazon ADM notification struct and convenience constructor functions.
Link to this section Summary
Functions
Creates ADM.Notification
struct with device registration ID and optional data payload.
Updates "data"
key on push payload and calculates md5
hash.
Link to this section Types
Specs
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
Specs
response() :: nil | :success | error_response() | :timeout
ADM push response
- nil - Push has not been sent yet
:success
- Push was successfully senterror_response/0
- Push attempted but server responded with error:timeout
- Internal error. Push did not reach ADM servers
Specs
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
}
Link to this section Functions
Specs
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
}