APNS wire-format encoding and decoding library.
Copyright (c) 2015 Silent Circle LLC
Authors: Edwin Fine (efine@silentcircle.com
).
This supports the simple (0), enhanced (1), and "v2" (2) formats.
apns_error() = term()
apns_notification() = term()
apns_packet() = binary()
bytes() = [byte()]
decode_err_pkt_error() = {error, decode_err_pkt_reason()}
decode_err_pkt_reason() = bad_packet
decode_error() = {error, decode_reason()}
decode_reason() = bad_packet | buffer_too_short | bad_json
decoded_packet() = {Timestamp::integer(), Token::binary()}
encode_error() = {error, encode_reason()}
encode_reason() = bad_token | bad_json | payload_too_long
json() = string() | binary()
token() = string() | bytes() | binary()
decode/1 | Decode an encoded APNS packet. |
decode_error_packet/1 | Decode an error received from APNS. |
decode_feedback_packet/1 | Decode a feedback packet received from APNS feedback service. |
encode_enhanced/4 | Encode the Id , Expiry , Token and Payload into an
"enhanced" (command 1) APNS packet. |
encode_simple/2 | Encode Token and Payload into a "simple" (command 0) APNS
packet. |
encode_v2/5 | Encode into the command 3 APNS packet. |
error_description/1 | Convert APNS error code to textual description (as binary string). |
error_to_atom/1 | Convert APNS error code to symbolic name (an atom). |
maybe_encode_token/1 |
decode(Packet) -> Result
Packet = binary()
Result = apns_notification() | decode_error()
Decode an encoded APNS packet.
decode_error_packet(ErrPkt) -> Result
ErrPkt = iolist() | binary()
Result = apns_error() | decode_err_pkt_error()
Decode an error received from APNS.
decode_feedback_packet(Packet) -> Result
Packet = list() | binary()
Result = [decoded_packet()]
Decode a feedback packet received from APNS feedback service.
encode_enhanced(Id, Expiry, Token, Payload) -> Result
Id = integer()
Expiry = integer()
Token = token()
Payload = json()
Result = apns_packet() | encode_error()
Encode the Id
, Expiry
, Token
and Payload
into an
"enhanced" (command 1) APNS packet.
encode_simple(Token, Payload) -> Result
Token = token()
Payload = json()
Result = apns_packet() | encode_error()
Encode Token
and Payload
into a "simple" (command 0) APNS
packet.
encode_v2(Id, Expiry, Token, Payload, Prio) -> Result
Id = integer()
Expiry = integer()
Token = token()
Payload = json()
Prio = integer()
Result = apns_packet() | encode_error()
Encode into the command 3 APNS packet.
error_description(Err) -> Desc
Err = integer()
Desc = binary()
Convert APNS error code to textual description (as binary string).
error_to_atom(Err) -> Atom
Err = 0..255
Atom = atom()
Convert APNS error code to symbolic name (an atom).
maybe_encode_token(L) -> any()