目录

CLASS info
public static class RemoteMessage.Notification implements Serializable
The RemoteMessage.Notification class is an internal class that indicates notification messages. When an app server sends a notification message, if the developer has configured the function on the server's open API that if the app is running in the foreground, the notification message is not displayed in the Notification Center (NC) but transparently transmitted to the app, the message is processed for display by the app. In this case, the RemoteMessage.Notification instance is contained in the RemoteMessage instance. The member fields defined in the Notification class map the fields defined in the AndroidNotification structure in Sending Messages. For apps running in the background or that do not exist, notification messages are displayed in the NC.

Public Method Summary

Return typeMethod name
StringgetTitle()
StringgetTitleLocalizationKey()
String[]getTitleLocalizationArgs()
StringgetBodyLocalizationKey()
String[]getBodyLocalizationArgs()
StringgetBody()
StringgetIcon()
StringgetSound()
StringgetTag()
StringgetColor()
StringgetClickAction()
StringgetChannelId()
UrigetImageUrl()
UrigetLink()
intgetNotifyId()
booleanisDefaultLight()
booleanisDefaultSound()
booleanisDefaultVibrate()
longgetWhen()
int[]getLightSettings()
IntegergetBadgeNumber()
booleanisAutoCancel()
IntegergetImportance()
StringgetTicker()
long[]getVibrateConfig()
intgetVisibility()
StringgetIntentUri()

Public Methods

Method
public String getTitle()
This method is used to obtain the title of a message.
Method
public String getTitleLocalizationKey()
This method is used to obtain the key of the localized title of a notification message for message display localization. To implement localization for notification messages, the key must be consistent with the node name defined in the strings.xml file of the app.
Method
public String[] getTitleLocalizationArgs()

This method is used to obtain variable string values in the localized title of a notification message. It must be used together with the getTitleLocalizationKey method. The key obtained by the getTitleLocalizationKey() method must be the same as the node name in the strings.xml file of the app, and the number of variable string values obtained by the getTitleLocalizationArgs method cannot be smaller than the number of placeholders in the value mapping the key in the strings.xml file. For details, please refer to Notification Message Localization in the development guide.

Example:

getTitleLocalizationKey: "demo_title_new"

getTitleLocalizationArgs: ["apple", "orange"]

Configuration in the strings.xml file:

  1. <string name="demo_title_new">I want eat %1$s and %2$s.</string>
Method
public String getBodyLocalizationKey()
This method is used to obtain the key of the localized content of a notification message for message display localization. To implement localization for notification messages, the key must be consistent with the node name defined in the strings.xml file of the app.
Method
public String[] getBodyLocalizationArgs()
This method is used to obtain variable string values in the localized content of a message. It must be used together with the getBodyLocalizationKey method. The key obtained by the getBodyLocalizationKey() method must be the same as the node name in the strings.xml file of the app, and the number of variable string values obtained by the getBodyLocalizationArgs method cannot be smaller than the number of placeholders in the value mapping the key in the strings.xml file. For details, please refer to Notification Message Localization in the development guide.
Method
public String getBody()
This method is used to obtain the displayed content of a message.
Method
public String getIcon()
This method is used to obtain the image resource name of a notification icon. On an Android device, all icon files are stored in the /res/raw/** directory of the app.

Return

typedesc
StringIcon resource file name, for example, /raw/ic_launcher, corresponding to the local file /res/raw/ic_launcher.png.
Method
public String getSound()
This method is used to obtain the name of an audio resource to be played when a notification message is displayed. On an Android device, all audio files are stored in the /res/raw/** directory of the app. If no audio resource is set, set this parameter to null.

Return

typedesc
StringAudio resource file name, for example, /raw/shake, corresponding to the local file /res/raw/shake.mp3.
Method
public String getTag()
This method is used to obtain the tag from a message for message overwriting. A message will be overwritten by another message with the same tag but is sent later.

Return

typedesc
StringMessage tag.
Method
public String getColor()
This method is used to obtain the colors (in #RRGGBB format) of icons in a message.

Return

typedesc
StringColors of icons in a message.
Method
public String getClickAction()
This method is used to obtain the action triggered upon notification message tapping. If no action is specified, null is returned. For the definition of actions, please refer to the definition in the ClickAction structure in Sending Messages of the development guide.

Return

typedesc
StringAction triggered upon notification message tapping. The action returned must be the same as the action declared in the intent-filter tag of Activity defined in AndroidManifest.xml.
Method
public String getChannelId()
This method is used to obtain IDs of channels that support the display of a message. If no channel is set, null is returned.

Return

typedesc
StringIDs of channels configured locally.
Method
public Uri getImageUrl()
This method is used to obtain the URL of an image in a message. The image URL must be a URL that can be accessed from the public network.

Return

typedesc
UriImage URL set by the developer. If no URL is set, null is returned.
Method
public Uri getLink()
This method is used to obtain the deep link from a message. A deep link is a specific URL, such as the URL of a web page or rich media. If no URL is set, null is returned.

Return

typedesc
UriURL in a message.
Method
public int getNotifyId()
This method is used to obtain the unique ID of a message. Different messages can have the same value of NotifyId, so that new messages can overwrite old messages.

Return

typedesc
intUnique ID of a message.
Method
public boolean isDefaultLight()
This method is used to check whether a notification message uses the default notification light settings. For details, please refer to the description of use_default_light in the AndroidNotification structure in Sending Messages.

Return

typedesc
booleanValue true or false.
Method
public boolean isDefaultSound()
This method is used to check whether a notification message uses the default sound. For details, please refer to the description of default_sound in the AndroidNotification structure in Sending Messages.

Return

typedesc
booleanValue true or false.
Method
public boolean isDefaultVibrate()
This method is used to check whether a notification message uses the default vibration mode. For details, please refer to the description of use_default_vibrate in the AndroidNotification structure in Sending Messages.

Return

typedesc
booleanValue true or false.
Method
public long getWhen()
This method is used to obtain the time (in milliseconds) when an event occurs from a notification message. Developers can sort notification messages by this time.
Method
public int[] getLightSettings()
This method is used to obtain the blinking frequency and color of a breathing light. For details, please refer to the description of light_settings in the AndroidNotification structure in Sending Messages.
Method
public Integer getBadgeNumber()
This method is used to obtain the number of notification messages.
Method
public boolean isAutoCancel()
This method is used to check whether a notification message is sticky. If true is returned, the notification message will disappear after a user taps it. If false is returned, the notification message will not disappear after a user taps it, but the user can swipe right or tap the brush icon to delete the message.

Return

typedesc
booleanValue true or false.
Method
public Integer getImportance()
This method is used to obtain the priority of a notification message.
Method
public String getTicker()
This method is used to obtain the text to be displayed on the status bar for a notification message.
Method
public long[] getVibrateConfig()
This method is used to obtain the vibration mode of a message. For details, please refer to the description of vibrate_config in the AndroidNotification structure in Sending Messages.

Return

typedesc
long[]Array consisting of at most 10 elements, with each in milliseconds.
Method
public int getVisibility()
This method is used to obtain the visibility of a notification message. For details, please refer to the definition of visibility in the AndroidNotification structure.
Method
public String getIntentUri()
This method is used to obtain the intent in a notification message. The intent can be opening a page specified by the app. For details, please refer to the definition of the intent parameter in the ClickAction structure in Sending Messages of the development guide.