| CLASS info |
| public final class RemoteMessage extends Object implements Parcelable |
The RemoteMessage class is a message entity class that uses the onMessageReceived(RemoteMessage) method to receive messages sent by the server. 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 from the HUAWEI Push Server. 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 the RemoteMessage instance. |
| Type | Name | Desc |
| Class | RemoteMessage.Notification | Notification message details in RemoteMessage. |
| Class | RemoteMessage.Builder | Constructor, which is used to construct a RemoteMessage instance. |
| Type | Name | Desc |
| int | PRIORITY_UNKNOWN | Unknown priority. |
| int | PRIORITY_HIGH | High priority. |
| int | PRIORITY_NORMAL | Normal priority. |
| Return type | Method name |
| String | getCollapseKey() Obtains the classification identifier (collapse key) of a message. |
| String | getData() Obtains the payload of a message. |
| Map<String, String> | Obtains the payload of a Map message. |
| String | getMessageId() Obtains the ID of a message. |
| String | getMessageType() Obtains the type of a message. |
| RemoteMessage.Notification | getNotification() Obtains the notification data instance from a message. |
| int | getOriginalUrgency() Obtains the message priority set by the app. |
| int | getUrgency() Obtains the message priority set on the HUAWEI Push Kit server. |
| int | getTtl() Obtains the maximum cache duration of a message. |
| long | getSentTime() Obtains the time when a message is sent from the server. |
| String | getTo() Obtains the recipient of a message. |
| String | getFrom() Obtains the resource of a message. |
| String | getToken() Obtains the token in a message. |
| android.os.Parcelable | void | writeToParcel(Parcel dest, int flags) Used in serialization and deserialization. |
| int | describeContents() Used in serialization and deserialization. |
| Constant |
| public static final int PRIORITY_UNKNOWN |
| Constant Value: 0 |
| Constant |
| public static final int PRIORITY_HIGH |
| Constant Value: 1 |
| Constant |
| public static final int PRIORITY_NORMAL |
| Constant Value: 2 |
| Method |
| public String getCollapseKey() |
| This method is used to obtain the classification identifier (collapse key) of a message. |
Return
| type | desc |
| String | Message classification identifier. |
Return
| type | desc |
| String | Message payload. If data in the message is set to "123", the getData() method returns "123". If data is set to {"k", "v"}, the getData() method returns the character string {"k", "v"} in JSON format. |
Return
| type | desc |
| String | Message source. |
| Method |
| public String getTo() |
| This method is used to obtain the recipient of a message. |
Return
| type | desc |
| String | Message recipient. |
| Method |
| public String getMessageId() |
| This method is used to obtain the ID of a message. |
Return
| type | desc |
| String | Message ID. |
| Method |
| public String getMessageType() |
| This method is used to obtain the type of a message. |
Return
| type | desc |
| String | Message type set by the developer and transparently transmitted by the SDK. |
| Method |
| public long getSentTime() |
| This method is used to obtain the time (in milliseconds) when a message is sent from the server. |
Return
| type | desc |
| long | Number of milliseconds from 00:00:00 on January 1, 1970 to the time when a message is sent from the server. |
| Method |
| public int getTtl() |
| This method is used to obtain the maximum cache duration (in seconds) of a message. For a downstream message, the value of ttl in the AndroidConfig structure is returned. |
Return
| type | desc |
| int | Maximum cache duration of a message, in seconds. |
| Method |
| public int getOriginalUrgency() |
| This method is used to obtain the message priority set by the app when it sends a message through an API of the HUAWEI Push Kit server. The priority is specified by AndroidConfig.urgency. |
Return
| type | desc |
| int | Message priority. For details, please refer to the definition in Constants of the RemoteMessage class. |
| Method |
| public int getUrgency() |
| This method is used to obtain the message priority set on the HUAWEI Push Kit server. |
Return
| type | desc |
| int | Message priority. For details, please refer to the definition in Constants of the RemoteMessage class. |
| Method |
| public RemoteMessage.Notification getNotification() |
| If notification data is configured in a message sent by the server, this method is called by an app to obtain the notification data from the message. |
Return
| type | desc |
| RemoteMessage.Notification | Notification message instance or null. |
| Method |
| public Map<String, String> getDataOfMap() |
| This method is used to obtain the payload of a Map message. Different from the getData method, this method directly returns a Map data instance or null (indicating an empty Map data instance). |
Return
| type | desc |
| Map<String, String> | If data is set to 123 in the message sent, the getData() method returns "123" and this method returns null. If data is set to {"k", "v"}, the getData() method returns {"k", "v"} in JSON format and this method returns a Map instance containing <k, v> in a specific format. |
| Method |
| public String getToken() |
| This method is used to obtain the token in a message. |
Return
| type | desc |
| String | Token. |