-
Notifications
You must be signed in to change notification settings - Fork 0
MulticastMessage
MulticastMessage
is an Anvil portable class specifically designed for sending Firebase Cloud Messaging (FCM) messages to multiple devices. It encapsulates various parameters such as data payload, web push configuration, FCM options, and a list of device tokens for targeting.
-
data (dict, optional)
: Key-value pairs that constitute the data payload of the message. -
webpush (WebpushConfig, optional)
: Configuration for web push notifications. -
fcm_options (WebpushFCMOptions, optional)
: FCM-specific options for the message. -
tokens (list[str], optional)
: A list of FCM device tokens, representing the devices to which the message will be sent. -
condition (str, optional)
: A condition expression specifying the devices that will receive the message.
Initializes a new instance of the MulticastMessage
class, facilitating the sending of an FCM message to multiple devices.
-
data (dict, optional)
: Data for the message. -
webpush (WebpushConfig, optional)
: Webpush configuration. -
fcm_options (WebpushFCMOptions, optional)
: FCM options. -
tokens (list[str], optional)
: Target device tokens. -
condition (str, optional)
: Conditional expression for targeting.
Converts the multicast message object to a dictionary, suitable for serialization and use with FCM SDKs.
A property that returns the type of the message, useful for identifying the message class in a system with multiple message types.
-
MulticastMessage
is designed for scenarios where you need to send the same message to multiple devices. - As an Anvil portable class, it can be used seamlessly between client and server code in Anvil applications.
- This class provides a structured approach to create and manage multicast messages for Firebase, ensuring efficient and organized communication.
from Firebase.messages import MulticastMessage
# Creating a multicast message
multicast_message = MulticastMessage(
data={"key1": "value1", "key2": "value2"},
tokens=["token1", "token2", "token3"]
)
# Converting the multicast message to a dictionary
multicast_message_dict = multicast_message.to_dict()
print(multicast_message_dict)
In this example, a MulticastMessage
is created with a specific data payload and a list of device tokens. The to_dict
method is used to convert the multicast message object into a dictionary format, which can then be used with Firebase SDKs for sending the message to the specified devices.
Home - Quick Start
Client
Messages
- Message
- SimpleMessage
- MulticastMessage
- WebpushConfig
- FCMOptions
- WebpushFCMOptions
- WebpushNotification
- WebpushNotificationAction
- Response
- BatchResponse
- TopicManagementResponse
Server