# `PushX.Message`
[🔗](https://github.com/cignosystems/pushx/blob/v0.11.0/lib/push_x/message.ex#L1)

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"})

# `t`

```elixir
@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
}
```

# `badge`

```elixir
@spec badge(t(), non_neg_integer()) :: t()
```

Sets the badge count (iOS).

# `body`

```elixir
@spec body(t(), String.t()) :: t()
```

Sets the body of the message.

# `category`

```elixir
@spec category(t(), String.t()) :: t()
```

Sets the notification category (iOS).

# `collapse_key`

```elixir
@spec collapse_key(t(), String.t()) :: t()
```

Sets the collapse key for message deduplication.

# `data`

```elixir
@spec data(t(), map()) :: t()
```

Sets custom data payload.

# `image`

```elixir
@spec image(t(), String.t()) :: t()
```

Sets the image URL for rich notifications.

# `new`

```elixir
@spec new() :: t()
```

Creates a new empty message.

## Examples

    iex> PushX.Message.new()
    %PushX.Message{title: nil, body: nil, data: %{}, priority: :high}

# `new`

```elixir
@spec new(String.t(), String.t()) :: t()
```

Creates a new message with title and body.

## Examples

    iex> PushX.Message.new("Hello", "World")
    %PushX.Message{title: "Hello", body: "World", data: %{}, priority: :high}

# `priority`

```elixir
@spec priority(t(), :high | :normal) :: t()
```

Sets the priority (:high or :normal).

# `put_data`

```elixir
@spec put_data(t(), atom() | String.t(), any()) :: t()
```

Adds a key-value pair to the data payload.

# `sound`

```elixir
@spec sound(t(), String.t()) :: t()
```

Sets the notification sound.

# `thread_id`

```elixir
@spec thread_id(t(), String.t()) :: t()
```

Sets the thread ID for notification grouping (iOS).

# `title`

```elixir
@spec title(t(), String.t()) :: t()
```

Sets the title of the message.

# `to_apns_payload`

```elixir
@spec to_apns_payload(t()) :: map()
```

Converts the message to an APNS payload map.

# `to_fcm_payload`

```elixir
@spec to_fcm_payload(t()) :: map()
```

Converts the message to an FCM payload map.

# `ttl`

```elixir
@spec ttl(t(), non_neg_integer()) :: t()
```

Sets the TTL (time to live) in seconds.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
