Skip to content

Latest commit

 

History

History
272 lines (135 loc) · 7.01 KB

apns_lib.md

File metadata and controls

272 lines (135 loc) · 7.01 KB

Module apns_lib

APNS wire-format encoding and decoding library.

Copyright (c) 2015 Silent Circle LLC

Authors: Edwin Fine (efine@silentcircle.com).

Description

This supports the simple (0), enhanced (1), and "v2" (2) formats.

Data Types


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()

Function Index

decode/1Decode an encoded APNS packet.
decode_error_packet/1Decode an error received from APNS.
decode_feedback_packet/1Decode a feedback packet received from APNS feedback service.
encode_enhanced/4Encode the Id, Expiry, Token and Payload into an "enhanced" (command 1) APNS packet.
encode_simple/2Encode Token and Payload into a "simple" (command 0) APNS packet.
encode_v2/5Encode into the command 3 APNS packet.
error_description/1Convert APNS error code to textual description (as binary string).
error_to_atom/1Convert APNS error code to symbolic name (an atom).
maybe_encode_token/1

Function Details

decode/1


decode(Packet) -> Result

Decode an encoded APNS packet.

decode_error_packet/1


decode_error_packet(ErrPkt) -> Result

Decode an error received from APNS.

decode_feedback_packet/1


decode_feedback_packet(Packet) -> Result

Decode a feedback packet received from APNS feedback service.

encode_enhanced/4


encode_enhanced(Id, Expiry, Token, Payload) -> Result

Encode the Id, Expiry, Token and Payload into an "enhanced" (command 1) APNS packet.

encode_simple/2


encode_simple(Token, Payload) -> Result

Encode Token and Payload into a "simple" (command 0) APNS packet.

encode_v2/5


encode_v2(Id, Expiry, Token, Payload, Prio) -> Result

Encode into the command 3 APNS packet.

error_description/1


error_description(Err) -> Desc
  • Err = integer()
  • Desc = binary()

Convert APNS error code to textual description (as binary string).

error_to_atom/1


error_to_atom(Err) -> Atom
  • Err = 0..255
  • Atom = atom()

Convert APNS error code to symbolic name (an atom).

maybe_encode_token/1

maybe_encode_token(L) -> any()