RemoteMessage

@SafeParcelable.Reserved(value = [1])
@SafeParcelable.Class(creator = "RemoteMessageCreator")
public final class RemoteMessage extends AbstractSafeParcelable


A remote Firebase Message.

Messages will be received via onMessageReceived and can be sent via send.

Messages may have a Notification instance if they are received while the application is in the foreground, otherwise they will be automatically posted to the notification tray.

Use the Builder class for building message instances to send via send.

Summary

Nested types

Builder object for constructing RemoteMessage instances.

@IntDef(value = )
@Retention(value = RetentionPolicy.SOURCE)
public annotation RemoteMessage.MessagePriority

Priority of the message

Remote Firebase notification details.

Constants

static final int
static final int
static final int

Public methods

@Nullable String

Gets the collapse key of the message.

@NonNull Map<StringString>

Gets the message payload data.

@Nullable String

Get the sender of this message.

@Nullable String

Gets the message's ID.

@Nullable String

Gets the type of message.

@Nullable RemoteMessage.Notification

Gets the notification data from the message if set.

int

Gets the original priority of message.

int

Gets the priority of message as delivered.

@Nullable String

Gets the Sender ID for the sender of this message.

long

Gets the time in milliseconds from the Epoch that the message was sent.

@Nullable String

Gets the message destination.

int

Gets the message time to live (TTL) in seconds.

void
writeToParcel(@NonNull Parcel out, int flags)

Inherited Constants

From android.os.Parcelable
static final int
static final int
From com.google.android.gms.common.internal.safeparcel.SafeParcelable
static final String
NULL = "SAFE_PARCELABLE_NULL_STRING"

Constants

PRIORITY_HIGH

public static final int PRIORITY_HIGH = 1

PRIORITY_NORMAL

public static final int PRIORITY_NORMAL = 2

PRIORITY_UNKNOWN

public static final int PRIORITY_UNKNOWN = 0

Public fields

data

public Map<StringStringdata

Public methods

getCollapseKey

public @Nullable String getCollapseKey()

Gets the collapse key of the message.

Returns
@Nullable String

The collapse key

getData

public @NonNull Map<StringStringgetData()

Gets the message payload data.

Returns
@NonNull Map<StringString>

A map of the message payload.

getFrom

public @Nullable String getFrom()

Get the sender of this message.

This will be the sender ID or the topic for topic messages.

Returns
@Nullable String

The message sender

getMessageId

public @Nullable String getMessageId()

Gets the message's ID.

This is automatically generated by the server. Treat it as an opaque string. Do not rely on its format to be consistent.

Returns
@Nullable String

The message ID

getMessageType

public @Nullable String getMessageType()

Gets the type of message.

Returns
@Nullable String

The message type

getNotification

public @Nullable RemoteMessage.Notification getNotification()

Gets the notification data from the message if set.

This field will be non-null if a notification message is received while the application is in the foreground.

Returns
@Nullable RemoteMessage.Notification

The message notification or null.

getOriginalPriority

@RemoteMessage.MessagePriority
public int getOriginalPriority()

Gets the original priority of message.

Returns
int

The original message priority

getPriority

@RemoteMessage.MessagePriority
public int getPriority()

Gets the priority of message as delivered. This may be lower than the priority originally requested.

Returns
int

The message priority as delivered

getSenderId

public @Nullable String getSenderId()

Gets the Sender ID for the sender of this message.

Returns
@Nullable String

the message Sender ID

getSentTime

public long getSentTime()

Gets the time in milliseconds from the Epoch that the message was sent.

Returns
long

The time that the message was sent

getTo

public @Nullable String getTo()

Gets the message destination.

  • For upstream messages, this will be of the form SENDER_ID@fcm.googleapis.com.
  • For downstream messages, this will be the Firebase installations ID (FID).

getTtl

public int getTtl()

Gets the message time to live (TTL) in seconds.

Returns
int

The message TTL

writeToParcel

public void writeToParcel(@NonNull Parcel out, int flags)