Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.
HMS Core
Class Info |
|---|
public class RemoteMessage implements Parcelable A message entity class. An app calls the onMessageReceived(RemoteMessage) method in HmsMessageService to receive messages pushed by the server and calls the send(RemoteMessage) method in HmsMessaging to send uplink messages. The RemoteMessage.Notification class is an internal class for processing notification messages. If you have called the Push Kit server's open API to specify that notification messages are not displayed in the NC when your app is running in the foreground, the notification messages will be transparently transmitted to and processed by your app for display. In this case, the RemoteMessage message instance contains a RemoteMessage.Notification data instance. The member field definition in the Notification class is mapped to the field definition in the AndroidNotification Structure in Sending Downlink Messages. For apps running in the background or that do not exist, notification messages are displayed in the NC. The RemoteMessage.Builder class is used to construct a RemoteMessage instance. All methods in this class take effect in EMUI 9.1 and later versions. |
Qualifier and Type | Class Name and Description |
|---|---|
public static class | A notification message details class in RemoteMessage. |
public static class | A constructor that is used to construct a RemoteMessage instance. |
Qualifier and Type | Method Name and Description |
|---|---|
String | Obtains the collapse key of a message. |
String | getData() Obtains the payload of a message. |
String | getFrom() Obtains the source of a message. |
String | getTo() Obtains the recipient of a message. |
String | Obtains the ID of a message. |
String | Obtains the type of a message. |
long | Obtains the time when a message is sent from your server. |
int | getTtl() Obtains the maximum cache duration of a message. |
| Obtains the notification data instance from a message. | |
Map<String, String> | Obtains the payload of a Map message. |
String | getToken() Obtains the token in a message. |
String | Obtains the tag of a message in a batch delivery task (bi_tag). |
Map<String, String> | Obtains the analysis data of the Map type. |
Method |
|---|
public String getCollapseKey() Obtains the collapse key of a message. For details, please refer to the description of setCollapseKey in RemoteMessage.Builder. |
Returns
Type | Description |
|---|---|
String | A message collapse key. |
Method |
|---|
public String getData() Obtains the message payload of the string type. |
Returns
Type | Description |
|---|---|
String | A common string or a string in JSON format, for example, "your data" or "{'param1':'value1', 'param2':'value2'}". If you call the methods for modifying message content at the same time (call addData method and then setData), the content modified by addData will be overwritten by the content modified by setData. In this case, after the getData method is called, the content modified by setData is returned. |
Method |
|---|
public String getFrom() Obtains the source of a message. You can use this method to obtain the ID of the project to which a message sent by the Push Kit server belongs. |
Returns
Type | Description |
|---|---|
String | A message source. |
Method |
|---|
public String getTo() Obtains the recipient of a message. |
Returns
Type | Description |
|---|---|
String | A message recipient. |
Method |
|---|
public String getMessageId() Obtains the ID of a message. |
Returns
Type | Description |
|---|---|
String | A message ID. |
Method |
|---|
public String getMessageType() Obtains the type of a message, which is set using setMessageType(String messageType) in RemoteMessage.Builder when you call send(RemoteMessage) in HmsMessaging to send uplink messages. The SDK transparently transmits the type to you. The message type is not set for data messages and notification messages, and the default value null is returned. |
Returns
Type | Description |
|---|---|
String | Message type that you set. |
Method |
|---|
public long getSentTime() Obtains the time (in milliseconds) when a message is sent from your server. |
Returns
Type | Description |
|---|---|
long | The number of milliseconds from 00:00:00 on January 1, 1970 to the time when a message is sent from your server. |
Method |
|---|
public int getTtl() Obtains the maximum cache duration of a message, in seconds. For a message that is sent by the server, the value of ttl set in AndroidConfig Structure in Sending Downlink Messages is returned; for uplink messages, the value in setTtl() in RemoteMessage.Builder is returned. |
Returns
Type | Description |
|---|---|
int | The maximum cache duration of a message, in seconds. |
Method |
|---|
public RemoteMessage.Notification getNotification() Obtains the notification data from a message if notification data is configured in a message sent by your server. |
Returns
Type | Description |
|---|---|
A notification message instance. |
Method |
|---|
public Map<String, String> getDataOfMap() Obtains the payload of a Map message. Different from the getData method, this method directly returns the instance of the Map data type. |
Returns
Type | Description |
|---|---|
Map<String, String> | If you set data to 123 in the message to be sent, the getData() method returns 123, and this method returns an empty Map-type instance. If you set data to {'param1':'value1'}, the getData() method returns the string in JSON format, for example, {'param1':'value1'}, and this method returns a Map-type instance containing {'param1':'value1'}. |
Method |
|---|
public String getToken() Obtains the token in a message. |
Returns
Type | Description |
|---|---|
String | A push token. |
Method |
|---|
public String getAnalyticInfo() Obtains the tag of a message in a batch delivery task (bi_tag). |
Returns
Type | Description |
|---|---|
String | A common string, for example, "your data". |
Method |
|---|
public Map<String, String> getAnalyticInfoMap() Obtains the analysis data of the Map type. Different from the getAnalyticInfo method, this method directly returns the instance of the Map type. |
Returns
Type | Description |
|---|---|
Map<String, String> | If you set bi_tag to 123 in the message to be sent, the getAnalyticInfo method returns 123, and this method returns an empty Map-type instance. If you set bi_tag to {'param1':'value1'}, the getAnalyticInfo method returns the string in JSON format, for example, {'param1':'value1'}, and this method returns a Map-type instance containing {'param1':'value1'}. |
Intelligent Assistant
Chat with our virtual assistant to get answers promptly.
Quick start
Helps you find desired resources with ease.