apns (apns v2.6.0)

Main module for apns4erl API. Use this one from your own applications.

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.

Summary

Functions

Closes the connection with APNs service.

Connects to APNs service

Connects to APNs service with Provider Certificate or Token

Get the default headers from environment variables.

Push notification to APNs. It will use the headers provided on the environment variables.

Push notification to certificate APNs Connection.

Push notification to APNs with authentication token. It will use the headers provided on the environment variables.

Push notification to authentication token APNs Connection.

Used when starting the application on the shell.

Stops the Application

Wait for the APNs connection to be up.

Types

-type device_id() :: binary().
-type headers() ::
          #{apns_id => binary(),
            apns_expiration => binary(),
            apns_priority => binary(),
            apns_topic => binary(),
            apns_collapse_id => binary(),
            apns_push_type => binary(),
            apns_auth_token => binary()}.
-type json() :: #{binary() => binary() | json()}.
-type response() :: {integer(), [term()], [term()] | no_body} | timeout.
-type token() :: binary().

Functions

Link to this function

close_connection(ConnectionId)

-spec close_connection(apns_connection:name() | pid()) -> ok.

Closes the connection with APNs service.

Link to this function

connect(Connection)

-spec connect(apns_connection:connection()) -> {ok, pid()}.

Connects to APNs service

Link to this function

connect(Type, ConnectionName)

-spec connect(apns_connection:type(), apns_connection:name()) -> {ok, pid()}.

Connects to APNs service with Provider Certificate or Token

Link to this function

default_headers()

-spec default_headers() -> apns:headers().

Get the default headers from environment variables.

Link to this function

generate_token(TeamId, KeyId)

-spec generate_token(binary(), binary()) -> token().
Link to this function

generate_token(TeamId, KeyId, KeyPath)

-spec generate_token(binary(), binary(), string()) -> token().
-spec get_feedback() -> [apns_feedback:feedback()] | {error, term()} | timeout.
Link to this function

get_feedback(Config)

-spec get_feedback(apns_feedback:feedback_config()) ->
                      [apns_feedback:feedback()] | {error, term()} | timeout.
Link to this function

push_notification(ConnectionId, DeviceId, JSONMap)

-spec push_notification(apns_connection:name() | pid(), device_id(), json()) ->
                           response() | {error, not_connection_owner}.

Push notification to APNs. It will use the headers provided on the environment variables.

Link to this function

push_notification(ConnectionId, DeviceId, JSONMap, Headers)

-spec push_notification(apns_connection:name() | pid(), device_id(), json(), headers()) ->
                           response() | {error, not_connection_owner}.

Push notification to certificate APNs Connection.

Link to this function

push_notification_token(ConnectionId, Token, DeviceId, JSONMap)

-spec push_notification_token(apns_connection:name() | pid(), token(), device_id(), json()) ->
                                 response() | {error, not_connection_owner}.

Push notification to APNs with authentication token. It will use the headers provided on the environment variables.

Link to this function

push_notification_token(ConnectionId, Token, DeviceId, JSONMap, Headers)

-spec push_notification_token(apns_connection:name() | pid(), token(), device_id(), json(), headers()) ->
                                 response() | {error, not_connection_owner}.

Push notification to authentication token APNs Connection.

-spec start() -> ok.

Used when starting the application on the shell.

-spec stop() -> ok.

Stops the Application

Link to this function

wait_for_connection_up(Server)

-spec wait_for_connection_up(pid()) -> ok.

Wait for the APNs connection to be up.