apns
Apple Push Notification Server for Erlang.
Apple Push Notification Server for Erlang
Types
alert() = apns_str()
| #loc_alert{body = none | apns:apns_str(),
action = none | apns:apns_str(),
key = apns:apns_str(),
args = [apns:apns_str()],
image = none | apns:apns_str()}
apns_str() = binary() | string()
conn_id() = atom() | pid()
connection() =
#apns_connection{apple_host = string(),
apple_port = integer(),
cert = undefined | binary(),
cert_file = string(),
key = undefined
| {'RSAPrivateKey' |
'DSAPrivateKey' |
'ECPrivateKey' |
'PrivateKeyInfo',
binary()},
key_file = undefined | string(),
cert_password = undefined | string(),
timeout = integer(),
error_fun =
fun((binary(), apns:status()) ->
stop | term()),
feedback_host = string(),
feedback_port = integer(),
feedback_fun =
fun(({calendar:datetime(), string()}) ->
term()),
feedback_timeout = integer() >= 1}
msg() =
#apns_msg{id = binary(),
expiry = integer() >= 0,
device_token = undefined | string(),
content_available = boolean(),
alert = none | apns:alert(),
badge = none | integer(),
sound = none | apns:apns_str(),
apns_extra = none
| [{atom(),
integer() | boolean() | string()}],
extra = [apns_mochijson2:json_property()]}
status() = no_errors
| processing_error
| missing_token
| missing_topic
| missing_payload
| missing_token_size
| missing_topic_size
| missing_payload_size
| invalid_token
| unknown
Functions
start() -> ok | {error, {already_started, apns}}
Starts the application
stop() -> ok
Stops the application
connect() -> {ok, pid()} | {error, Reason::term()}
Opens an unnamed connection using the default parameters
connect(Name::atom() | string() | (string()) -> term() | connection()) -> {ok, pid()} | {error, {already_started, pid()}} | {error, Reason::term()}
Opens an unnamed connection using the given feedback or error function or using the given connection() parameters or the name and default configuration if a name is given
connect(Name::atom(), Connection::string() | (string()) -> term() | connection()) -> {ok, pid()} | {error, {already_started, pid()}} | {error, Reason::term()}
Opens an connection named after the atom() using the given feedback or error function or using the given connection() parameters
connect(Name::atom(), ErrorFun::(binary(), status() (see module apns)) -> stop | term(), FeedbackFun::(string()) -> term()) -> {ok, pid()} | {error, {already_started, pid()}} | {error, Reason::term()}
Opens an connection named after the atom() using the given feedback and error functions
disconnect(ConnId::conn_id()) -> ok
Closes an open connection
send_message(ConnId::conn_id(), Msg::msg()) -> ok
Sends a message to Apple
send_content_available(ConnId::conn_id(), DeviceToken::string()) -> ok
Sends a message to Apple with content_available: 1
send_content_available(ConnId::conn_id(), DeviceToken::string(), Alert::string()) -> ok
Sends a message to Apple with content_available: 1 and an alert
send_badge(ConnId::conn_id(), DeviceToken::string(), Badge::integer()) -> ok
Sends a message to Apple with just a badge
send_message(ConnId::conn_id(), DeviceToken::string(), Alert::alert()) -> ok
Sends a message to Apple with just an alert
send_message(ConnId::conn_id(), Token::string(), Alert::alert(), Badge::integer()) -> ok
Sends a message to Apple with an alert and a badge
send_message(ConnId::conn_id(), Token::string(), Alert::alert(), Badge::integer(), Sound::apns_str()) -> ok
Sends a full message to Apple
estimate_available_bytes(Apns_msg::msg()) -> integer()
Predicts the number of bytes left in a message for additional data.
send_message(ConnId::conn_id(), Token::string(), Alert::alert(), Badge::integer(), Sound::apns_str(), Expiry::non_neg_integer()) -> ok
Sends a full message to Apple (complete with expiry)
send_message(ConnId::conn_id(), Token::string(), Alert::alert(), Badge::integer(), Sound::apns_str(), Expiry::non_neg_integer(), ExtraArgs::[json_property() (see module apns_mochijson2)]) -> ok
Sends a full message to Apple with expiry and extra arguments
send_message(ConnId::conn_id(), MsgId::binary(), DeviceToken::string(), Alert::alert(), Badge::integer(), Sound::apns_str(), Expiry::non_neg_integer(), ExtraArgs::[json_property() (see module apns_mochijson2)]) -> ok
Sends a full message to Apple with id, expiry and extra arguments
message_id() -> binary()
Generates an "unique" and valid message Id
expiry(Secs::none | {{1970..9999, 1..12, 1..31}, {0..24, 0..60, 0..60}} | pos_integer()) -> non_neg_integer()
Generates a valid expiry value for messages.
If called with none
as the parameter, it will return a
no-expire
value.
If called with a datetime as the parameter, it will convert it to a
valid expiry value.
If called with an integer, it will add that many seconds to current
time and return a valid expiry value for that date.