RemoteMessage

@SafeParcelable.Reserved(value = [1])
@SafeParcelable.Class(creator = "RemoteMessageCreator")
public final classRemoteMessage extendsAbstractSafeParcelable


A remote Firebase Message.

Messages will be received viaonMessageReceived.

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

Summary

Nested types

Builder object for constructingRemoteMessage instances.

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

Priority of the message

Remote Firebase notification details.

Constants

static final int
static final int
static final int

Public methods

@NullableString

Gets the collapse key of the message.

@NonNullMap<StringString>

Gets the message payload data.

@NullableString

Get the sender of this message.

@NullableString

Gets the message's ID.

@NullableString

Gets the type of message.

@NullableRemoteMessage.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.

@NullableString

Gets the Sender ID for the sender of this message.

long

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

@NullableString

This method is deprecated.

This function is actuallydecommissioned along with all of FCM upstream messaging.

int

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

void
writeToParcel(@NonNullParcel out, int flags)

Inherited Constants

Fromandroid.os.Parcelable
static final int
static final int
Fromcom.google.android.gms.common.internal.safeparcel.SafeParcelable
static finalString
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 @NullableString getCollapseKey()

Gets the collapse key of the message.

Returns
@NullableString

The collapse key

getData

public @NonNullMap<StringStringgetData()

Gets the message payload data.

Returns
@NonNullMap<StringString>

A map of the message payload.

getFrom

public @NullableString getFrom()

Get the sender of this message.

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

Returns
@NullableString

The message sender

getMessageId

public @NullableString 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
@NullableString

The message ID

getMessageType

public @NullableString getMessageType()

Gets the type of message.

Returns
@NullableString

The message type

getNotification

public @NullableRemoteMessage.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
@NullableRemoteMessage.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 @NullableString getSenderId()

Gets the Sender ID for the sender of this message.

Returns
@NullableString

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

getTtl

public int getTtl()

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

Returns
int

The message TTL

writeToParcel

public void writeToParcel(@NonNullParcel out, int flags)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.