View Source Appwrite.Services.Messaging (appwrite v0.2.1)

The Messaging service allows you to send messages to any provider type (SMTP, push notification, SMS, etc.).

Using the Messaging service, you can send targeted messages to users based on topics or one-time messages directly to users. Providers can be configured in the Appwrite console.

Summary

Functions

Create a new subscriber for a topic.

Delete a subscriber by its unique ID.

Functions

create_subscriber(topic_id, subscriber_id, target_id)

@spec create_subscriber(String.t(), String.t(), String.t()) ::
  {:ok, Appwrite.Types.Subscriber.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

Create a new subscriber for a topic.

Subscribes a user's messaging target to the specified topic so that messages sent to the topic are delivered to that target.

Parameters

  • topic_id (String.t()): The ID of the topic to subscribe to.
  • subscriber_id (String.t()): Unique subscriber ID. Use a custom ID or generate one with ID.unique(). Valid chars: a-z, A-Z, 0-9, ., -, _. Cannot start with a special character. Max length: 36 chars.
  • target_id (String.t()): The target ID to link to this topic.

Returns

  • {:ok, Subscriber.t()} on success.
  • {:error, AppwriteException.t()} on failure.

Examples

iex> Appwrite.Services.Messaging.create_subscriber("topic_id", "unique()", "target_id")
{:ok, %Appwrite.Types.Subscriber{}}

delete_subscriber(topic_id, subscriber_id)

@spec delete_subscriber(String.t(), String.t()) ::
  {:ok, map()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Delete a subscriber by its unique ID.

Parameters

  • topic_id (String.t()): The ID of the topic the subscriber belongs to.
  • subscriber_id (String.t()): The subscriber ID.

Returns

  • {:ok, map()} on success.
  • {:error, AppwriteException.t()} on failure.

Examples

iex> Appwrite.Services.Messaging.delete_subscriber("topic_id", "subscriber_id")
{:ok, %{}}