| CLASS info |
| public static class RemoteMessage.Builder extends Object |
| Constructs a RemoteMessage instance. |
| Constructor name |
public RemoteMessage.Builder(String to) Argument constructor of the RemoteMessage.Builder class. |
| Return type | Method name |
| RemoteMessage.Builder | addData(String key, String value) Adds key-value pair data to a message. |
| RemoteMessage.Builder | setData(Map<String, String> map) Sets Map data to a message. |
| RemoteMessage.Builder | Deletes message data. |
| RemoteMessage.Builder | setMessageId(String messageId) Sets the ID of a message. |
| RemoteMessage.Builder | setMessageType(String messageType) Sets the type of a message. |
| RemoteMessage.Builder | setTtl(int ttl) Sets the maximum cache duration of a message, in seconds. |
| RemoteMessage.Builder | setCollapseKey(String collapseKey) Sets the classification identifier of a message. |
| RemoteMessage.Builder | setSendMode(int sendMode) Sets whether to enable the message cache and resending capability of the Push Kit client. |
| RemoteMessage.Builder | setReceiptMode(int receiptMode) Sets the receipt capability after an uplink message is sent to the app server. |
| RemoteMessage | build() Constructs a RemoteMessage instance. |
| constructor |
| public Builder(String to) |
Argument constructor of the RemoteMessage.Builder class to construct an object with to as the input parameter |
Parameters
| Parameter name | Parameter desc |
| to | For an uplink message, the value is always push.hcm.upstream. |
| Method |
| public RemoteMessage.Builder addData(String key, String value) |
| This method is used to add key-value pair data to a message. |
Parameters
| Parameter name | Parameter desc |
| key | Key in a key-value pair, for example, name. |
| value | Value in a key-value pair, for example, ZhangSan. |
Throws
| Throw name | Throw desc |
| IllegalArgumentException | Exception thrown when key is null. |
| Method |
| public RemoteMessage.Builder setData(Map<String, String> map) |
| This method is used to specify message data to Map data. All existing data will be deleted. |
Parameters
| Parameter name | Parameter desc |
| map | Map data provided by Java. |
| Method |
| public RemoteMessage.Builder clearData() |
| This method is used to delete the message data of the Builder instance. |
| Method |
| public RemoteMessage.Builder setMessageId(String messageId) |
| This method is used to set the ID of a message. |
Parameters
| Parameter name | Parameter desc |
| messageId | Message ID, which is generated by an app and is unique for each message. |
| Method |
| public RemoteMessage.Builder setMessageType(String messageType) |
| This method is used to set the type of an upstream message or device group message sent through the send(RemoteMessage) method. The message type is transparently transmitted by the SDK. |
Parameters
| Parameter name | Parameter desc |
| messageType | Message type specified by the developer. |
Parameters
| Parameter name | Parameter desc |
| ttl | Maximum cache duration of an offline message set for HUAWEI Push Kit, in seconds. The duration can be set to 15 days at most. |
Throws
| Throw name | Throw desc |
| IllegalArgumentException | The value of the input parameter ttl must be within the range [0,1296000]. Otherwise, the system throws IllegalArgumentException, indicating that invalid parameters exist. |
Parameters
| Parameter name | Parameter desc |
| collapseKey | If you set collapse_key to -1, all offline messages of the app are sent to the device.If you set collapse_key to 0, offline messages of the app sent to the device are determined by the default policy of HUAWEI Push. Generally, only the latest offline message is sent to the device.You can set collapse_key to a value ranging from 1 to 100 to group messages. For example, if you send 10 messages and set collapse_key to 1 for the first five messages and to 2 for the rest, the latest offline message whose value of collapse_key is 1 and the latest offline message whose value of collapse_key is 2 are sent to the device. |
Parameters
| Parameter name | Parameter desc |
sendMode | The value can be 0 or 1. The value 1 indicates that the cache and resending capability is enabled. |
Throws
| Throw name | Throw desc |
| IllegalArgumentException | Exception thrown if the value is not 0 or 1. |
Parameters
| Parameter name | Parameter desc |
receiptMode | The value can be 0 or 1. The value 1 indicates that the receipt capability is enabled after messages are sent. |
Throws
| Throw name | Throw desc |
| IllegalArgumentException | Exception thrown if the value is not 0 or 1. |
| Method |
| public RemoteMessage build() |
| This method is used to construct a RemoteMessage instance. |
Throws
| Throw name | Throw desc |
| Exception | Exception that occurs when the build method is called. You can obtain the exception description by using the Exception.getMessage() method. |
Return
| type | desc |
| RemoteMessage | Returns a RemoteMessage instance. |