Client for the Bubbles Push Notifications API.
Public API:
initialize/2- builds a reusable client withapp_idandapi_keycreate_notification/2- posts a notification using that clientsend_push_to_device/3- sends a push directly to a device id
The API base URL is read from application config:
config :bubbles_notifications,
base_url: "https://your-api.example.com"
Summary
Functions
Creates a notification for the initialized app.
Creates a notification for devices with the given user ID strings and for devices with at least one of the given alias strings.
Initializes a notification client with the app id and API key.
Creates a notification for the given device id.
Types
@type attribute_filters() :: map()
@type device_push_params() :: message_params()
@type error_response() :: %{status: pos_integer(), body: map()}
@type notification_params() :: %{ :title => String.t(), :body => String.t(), :data => map(), optional(:attribute_filters) => attribute_filters() }
@type response() :: {:ok, notification()} | {:error, error_response() | Exception.t()}
Functions
@spec create_notification(t(), notification_params()) :: response()
Creates a notification for the initialized app.
The payload must include:
:title:body:data:attribute_filters(optional)
:app_id is taken from the initialized client.
@spec create_notification_user_ids_aliases( t(), [String.t()], [String.t()], notification_params() ) :: response()
Creates a notification for devices with the given user ID strings and for devices with at least one of the given alias strings.
The payload must include:
:title:body:data:attribute_filters(optional)
:app_id is taken from the initialized client.
Initializes a notification client with the app id and API key.
The base URL is loaded from Application.fetch_env!(:bubbles_notifications, :base_url).
Examples
iex> client = BubblesNotifications.initialize(42, "secret-token")
iex> client.app_id
42
@spec send_push_to_device( t(), integer() | String.t() | charlist(), device_push_params() ) :: response()
Creates a notification for the given device id.
The payload must include:
:title:body:data
:app_id is taken from the initialized client.