Module apns_connection

This gen_server handles the APNs Connection.

Copyright © Inaka <hello@inaka.net>

Behaviours: gen_server.

Description

This gen_server handles the APNs Connection.

Copyright 2017 Erlang Solutions Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Data Types

connection()

connection() = #{name := name(), apple_host := host(), apple_port := inet:port_number(), certdata => binary(), certfile => path(), keydata => keydata(), keyfile => path(), timeout => integer(), type := type()}

host()

host() = string() | inet:ip_address()

keydata()

keydata() = {'RSAPrivateKey' | 'DSAPrivateKey' | 'ECPrivateKey' | 'PrivateKeyInfo', binary()}

name()

name() = atom()

notification()

notification() = binary()

path()

path() = string()

state()

state() = #{connection := connection(), http2_connection := pid(), client := pid(), backoff := non_neg_integer(), backoff_ceiling := non_neg_integer()}

type()

type() = certdata | cert | token

Function Index

certdata/1
certfile/1
close_connection/1Close the connection with APNs gracefully.
code_change/3
default_connection/2Builds a connection() map from the environment variables.
handle_call/3
handle_cast/2
handle_info/2
host/1
http2_connection/1Returns the http2's connection PID.
init/1
keydata/1
keyfile/1
name/1
port/1
push_notification/4Pushes notification to certificate APNs connection.
push_notification/5Pushes notification to certificate APNs connection.
start_link/2starts the gen_server.
terminate/2
type/1

Function Details

certdata/1

certdata(X1::connection()) -> binary()

certfile/1

certfile(X1::connection()) -> path()

close_connection/1

close_connection(ConnectionId::name() | pid()) -> ok

Close the connection with APNs gracefully

code_change/3

code_change(OldVsn::term() | {down, term()}, State, Extra::term()) -> {ok, State}

default_connection/2

default_connection(X1::type(), ConnectionName::name()) -> connection()

Builds a connection() map from the environment variables.

handle_call/3

handle_call(Request::term(), From::{pid(), term()}, State) -> {reply, term(), State}

handle_cast/2

handle_cast(Request::term(), State) -> {noreply, State}

handle_info/2

handle_info(Info::timeout() | term(), State) -> {noreply, State}

host/1

host(X1::connection()) -> host()

http2_connection/1

http2_connection(ConnectionId::name() | pid()) -> pid()

Returns the http2's connection PID. This function is only used in tests.

init/1

init(X1::{connection(), pid()}) -> {ok, State::state()}

keydata/1

keydata(X1::connection()) -> keydata()

keyfile/1

keyfile(X1::connection()) -> path()

name/1

name(X1::connection()) -> name()

port/1

port(X1::connection()) -> inet:port_number()

push_notification/4

push_notification(ConnectionId::name() | pid(), DeviceId::apns:device_id(), Notification::notification(), Headers::apns:headers()) -> apns:response() | {error, not_connection_owner}

Pushes notification to certificate APNs connection.

push_notification/5

push_notification(ConnectionId::name() | pid(), Token::apns:token(), DeviceId::apns:device_id(), Notification::notification(), Headers::apns:headers()) -> apns:response() | {error, not_connection_owner}

Pushes notification to certificate APNs connection.

start_link/2

start_link(Connection::connection(), Client::pid()) -> {ok, Pid::pid()} | ignore | {error, Reason::term()}

starts the gen_server

terminate/2

terminate(Reason::normal | shutdown | {shutdown, term()} | term(), State::state()) -> ok

type/1

type(X1::connection()) -> type()


Generated by EDoc, Jul 12 2017, 06:09:38.