pushex v0.2.3 Pushex.Helpers View Source

Module containing helpers functions to use Pushex functionalities easily.

Link to this section Summary

Functions

Sends a notification asynchrnously. The first argument can be a notification or a full request (i.e. a Pushex.GCM.Request)

Link to this section Functions

Link to this function

send_notification(request, opts \\ [])

View Source
send_notification(
  Pushex.GCM.request() | Pushex.APNS.request() | map(),
  Keyword.t()
) :: reference()

Sends a notification asynchrnously. The first argument can be a notification or a full request (i.e. a Pushex.GCM.Request)

When using the first form, all the options passed will be passed to the request (e.g. :priority)

The function raises an exception if the request cannot be executed, for example if a parameter is missing, or the requested application is not found. If the request is executed but fails, it should be handled in the response handler.

Examples

notification = %{title: "my title", body: "my body"}

app    = %Pushex.GCM.App{name: "some name", auth_key: "my_auth_key"}
reg_id = get_my_registration_id
Pushex.push(notification, to: reg_id, with_app: app)

# with default_app setup
Pushex.push(notification, to: reg_id, using: :gcm)


request = %Pushex.GCM.Request{app: app, notification: notification, to: reg_id}
Pushex.push(request)