A struct representing a push notification message.
Provides a builder API for constructing notifications with title, body, badge, sound, and custom data.
Examples
# Simple message
message = PushX.Message.new("Hello", "World")
# Builder pattern
message = PushX.Message.new()
|> PushX.Message.title("Order Update")
|> PushX.Message.body("Your order has been shipped!")
|> PushX.Message.badge(1)
|> PushX.Message.sound("default")
|> PushX.Message.data(%{order_id: "12345"})
Summary
Functions
Sets the badge count (iOS).
Sets the body of the message.
Sets the notification category (iOS).
Sets the collapse key for message deduplication.
Sets custom data payload.
Sets the image URL for rich notifications.
Creates a new empty message.
Creates a new message with title and body.
Sets the priority (:high or :normal).
Adds a key-value pair to the data payload.
Sets the notification sound.
Sets the thread ID for notification grouping (iOS).
Sets the title of the message.
Converts the message to an APNS payload map.
Converts the message to an FCM payload map.
Sets the TTL (time to live) in seconds.
Types
@type t() :: %PushX.Message{ badge: non_neg_integer() | nil, body: String.t() | nil, category: String.t() | nil, collapse_key: String.t() | nil, data: map(), image: String.t() | nil, priority: :high | :normal, sound: String.t() | nil, thread_id: String.t() | nil, title: String.t() | nil, ttl: non_neg_integer() | nil }
Functions
@spec badge(t(), non_neg_integer()) :: t()
Sets the badge count (iOS).
Sets the body of the message.
Sets the notification category (iOS).
Sets the collapse key for message deduplication.
Sets custom data payload.
Sets the image URL for rich notifications.
@spec new() :: t()
Creates a new empty message.
Examples
iex> PushX.Message.new()
%PushX.Message{title: nil, body: nil, data: %{}, priority: :high}
Creates a new message with title and body.
Examples
iex> PushX.Message.new("Hello", "World")
%PushX.Message{title: "Hello", body: "World", data: %{}, priority: :high}
Sets the priority (:high or :normal).
Adds a key-value pair to the data payload.
Sets the notification sound.
Sets the thread ID for notification grouping (iOS).
Sets the title of the message.
Converts the message to an APNS payload map.
Converts the message to an FCM payload map.
@spec ttl(t(), non_neg_integer()) :: t()
Sets the TTL (time to live) in seconds.