RemoteMessage.Builder

class RemoteMessage.Builder


Builder object for constructing RemoteMessage instances.

Summary

Public constructors

Sets the destination of the message.

Public functions

RemoteMessage.Builder
addData(key: String, value: String?)

Adds a data key value pair to the message.

RemoteMessage

Build a RemoteMessage instance.

RemoteMessage.Builder

Clears the message data.

RemoteMessage.Builder
setCollapseKey(collapseKey: String?)

Sets the collapse key of the message.

RemoteMessage.Builder
setMessageId(messageId: String)

Sets the messages ID.

RemoteMessage.Builder
setMessageType(messageType: String?)

Sets the type of message.

RemoteMessage.Builder
setTtl(ttl: @IntRange(from = 0, to = 86400) Int)

Sets the message time to live in seconds.

Public properties

(Mutable)Map<String!, String!>!

Public constructors

Builder

Builder(to: String)

Sets the destination of the message.

Parameters
to: String

The destination of the message in the format of [email protected]. The SENDER_ID should be the FirebaseApp gcm sender id.

Public functions

addData

fun addData(key: String, value: String?): RemoteMessage.Builder

Adds a data key value pair to the message.

An existing value with the same key will be replaced by the new value.

build

fun build(): RemoteMessage

Build a RemoteMessage instance.

clearData

fun clearData(): RemoteMessage.Builder

Clears the message data.

setCollapseKey

fun setCollapseKey(collapseKey: String?): RemoteMessage.Builder

Sets the collapse key of the message.

A pending message will be replaced by a new message with the same collapse key if it is currently unable to be delivered to the recipient.

setMessageId

fun setMessageId(messageId: String): RemoteMessage.Builder

Sets the messages ID.

Parameters
messageId: String

ID of the message. This is generated by the application. It must be unique for each message. This allows error callbacks and debugging.

setMessageType

fun setMessageType(messageType: String?): RemoteMessage.Builder

Sets the type of message.

setTtl

fun setTtl(ttl: @IntRange(from = 0, to = 86400) Int): RemoteMessage.Builder

Sets the message time to live in seconds.

If 0, the message send will be attempted immediately and will be dropped if the device is not connected. Otherwise, the message will be queued.

Public properties

data

var data: (Mutable)Map<String!, String!>!