Summary: Ctors | Methods | Inherited Methods | [Expand All]
public static class

# RemoteMessage.Builder

extends Object

java.lang.Object
↳ | com.google.firebase.messaging.RemoteMessage.Builder

## Class Overview

Builder object for constructing `RemoteMessage` instances.

## Summary

Public Constructors
| RemoteMessage.Builder(String to) Set the destination of the message.

Public Methods
RemoteMessage.Builder | addData(String key, String value) Add a data key value pair to the message.
RemoteMessage | build() Build a RemoteMessage instance.
RemoteMessage.Builder | clearData() Clear the message data.
RemoteMessage.Builder | setCollapseKey(String collapseKey) Set the collapse key of the message.
RemoteMessage.Builder | setData(Map<String, String> data) Set the message data to the contents of .
RemoteMessage.Builder | setMessageId(String messageId) Set the messages ID.
RemoteMessage.Builder | setMessageType(String messageType) Set the type of message.
RemoteMessage.Builder | setTtl(int ttl) Set the message time to live in seconds.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public RemoteMessage.Builder (String to)

Set the destination of the message.

##### Parameters

to | The destination of the message in the format of `SENDER_ID@gcm.googleapis.com`. The `SENDER_ID` should be one of the sender IDs used when calling `getToken(String, String)`.

## Public Methods

#### public RemoteMessage.Builder addData (String key, String value)

Add a data key value pair to the message. An existing value with the same key will be replaced by the new value.

#### public RemoteMessage build ()

Build a RemoteMessage instance.

#### public RemoteMessage.Builder clearData ()

Clear the message data.

#### public RemoteMessage.Builder setCollapseKey (String collapseKey)

Set 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.

#### public RemoteMessage.Builder setData (Map<String, String> data)

Set the message data to the contents of . Any existing data will be removed.

#### public RemoteMessage.Builder setMessageId (String messageId)

Set the messages ID.

##### Parameters

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

#### public RemoteMessage.Builder setMessageType (String messageType)

Set the type of message.

#### public RemoteMessage.Builder setTtl (int ttl)

Set 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.