Apple Push Notification Service (APNS) API.
Copyright (c) 2015 Silent Circle
Behaviours: supervisor
.
Authors: Edwin Fine (efine@silentcircle.com
).
This is the API to the Apple Push Notification Service Provider.
Opts = [
{host, "gateway.sandbox.push.apple.com"},
{port, 2195},
{bundle_seed_id, <<"com.example.Push">>},
{bundle_id, <<"com.example.Push">>},
{ssl_opts, [
{certfile, "/somewhere/cert.pem"},
{keyfile, "/somewhere/key.unencrypted.pem"}
]
}
],
{ok, Pid} = sc_push_svc_apns:start_session(my_push_tester, Opts).
Notification = [{alert, Alert}, {token, <<"e7b300...a67b">>}],
{ok, SeqNo} = sc_push_svc_apns:send(my_push_tester, Notification).
JSON = get_json_payload(), % See APNS docs for format
{ok, SeqNo} = apns_erl_session:send(my_push_tester, Token, JSON).
ok = sc_push_svc_apns:stop_session(my_push_tester).
gen_proplist() = sc_types:proplist(atom(), term())
async_send/2 | Asynchronously sends a notification specified by proplist Notification
to SvrRef ; Same as send/2 beside returning only 'ok' for success. |
async_send/3 | Asynchronously sends a notification specified by proplist Notification
to SvrRef ; Same as send/3 beside returning only 'ok' for success. |
init/1 | |
send/2 | Send a notification specified by proplist Notification
to SvrRef . |
send/3 | Send a notification specified by proplist Notification
via SvrRef using options Opts . |
start_link/1 | Opts is a list of proplists. |
start_session/2 | Start named session for specific host and certificate as
supplied in the proplist Opts . |
stop_session/1 | Stop named session. |
async_send(Name::term(), Notification::gen_proplist()) -> ok | {error, Reason::term()}
Asynchronously sends a notification specified by proplist Notification
to SvrRef
; Same as send/2
beside returning only 'ok' for success.
async_send(Name::term(), Notification::gen_proplist(), Opts::gen_proplist()) -> ok | {error, Reason::term()}
Asynchronously sends a notification specified by proplist Notification
to SvrRef
; Same as send/3
beside returning only 'ok' for success.
init(Opts) -> any()
send(Name::term(), Notification::gen_proplist()) -> {ok, Ref::term()} | {error, Reason::term()}
Send a notification specified by proplist Notification
to SvrRef
.
Set the notification to expire in a very very long time.
Send an alert with a sound and extra data
Name = 'com.example.AppId',
Notification = [
{alert, <<"Hello">>},
{token, <<"ea3f...">>},
{aps, [
{sound, <<"bang">>},
{extra, [{a, 1}]}]}
],
sc_push_svc_apns:send(Name, Notification).
See also: send/3.
send(Name::term(), Notification::gen_proplist(), Opts::gen_proplist()) -> {ok, Ref::term()} | {error, Reason::term()}
Send a notification specified by proplist Notification
via SvrRef
using options Opts
.
Note that Opts
currently has no supported actions.
start_link(Opts::list()) -> {ok, pid()} | {error, term()}
Opts
is a list of proplists.
Each proplist is a session definition containing
name, mod, and config keys.
start_session(Name::atom(), Opts::list()) -> {ok, pid()} | {error, already_started} | {error, Reason::term()}
Start named session for specific host and certificate as
supplied in the proplist Opts
.
See also: apns_erl_session_sup:start_child/2.
stop_session(Name::atom()) -> ok | {error, Reason::term()}
Stop named session.