| CLASS info |
| public final class RemoteMessage extends Object implements Parcelable |
RemoteMessage类是一个消息实体类,App通过onMessageReceived(RemoteMessage)方法接收服务端推送的消息。 RemoteMessage.Notification类是一个数据类,代表通知消息。当您在服务端推送通知消息时,通过服务端提供的开放接口设置了如果应用进程在前台则不通过华为的统一消息中心(Notification Center, 简称NC)展示消息,那么应用在前台时这个通知消息是直接透传给应用,由应用自己处理展示,此时RemoteMessage消息实体中包含RemoteMessage.Notification数据实例。Notification类中成员字段定义与服务端发送Push消息中的AndroidNotification结构体字段定义相映射。如果应用进程在后台或者不存在,通知消息都是通过NC展示。 RemoteMessage.Builder类用于构建RemoteMessage消息实例。 |
| Type | Name | Desc |
| Class | RemoteMessage.Notification | RemoteMessage消息中的通知消息详情。 |
| Class | RemoteMessage.Builder | 构建类,用于构建RemoteMessage消息实例。 |
| Type | Name | Desc |
| int | PRIORITY_UNKNOWN | 未知优先级 |
| int | PRIORITY_HIGH | 高优先级 |
| int | PRIORITY_NORMAL | 普通优先级 |
| Return type | Method name |
| String | getCollapseKey() 获取消息的分类标识(折叠键) |
| String | getData() 获取消息的有效内容数据 |
| Map<String, String> | 获取Map类型的消息内容数据 |
| String | getMessageId() 获取消息Id |
| String | getMessageType() 获取消息的类型 |
| RemoteMessage.Notification | getNotification() 从消息中获取通知数据实例 |
| int | getOriginalUrgency() 获取应用设置的消息优先级 |
| int | getUrgency() 获取Push服务端设置的消息优先级 |
| int | getTtl() 获取消息的最大缓存时间 |
| long | getSentTime() 获取消息从服务端下发的时间 |
| String | getTo() 获取消息的目的地 |
| String | getFrom() 获取消息的来源 |
| String | getToken() 获取消息中的令牌 |
| android.os.Parcelable | void | writeToParcel(Parcel dest, int flags) 该方法在序列化和反序列化时使用。 |
| int | describeContents() 该方法在序列化和反序列化时使用。 |
| 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() |
| 获取消息的分类标识(折叠健)。 |
Return
| type | desc |
| String | 消息分类标识 |
Return
| type | desc |
| String | 消息内容,如果开发者发送消息中data字段设置为"123",则getData()方法返回"123";data字段设置为{"k", "v"},则getData()方法返回JSON格式的字符串{"k", "v"}。 |
| Method |
| public String getFrom() |
| 获取消息的来源,Push服务端在下发消息时会设置本消息归属的应用的appid在消息体中,您可以通过本方法来获取。 |
Return
| type | desc |
| String | 消息的来源 |
| Method |
| public String getTo() |
| 获取消息的目的地。 |
Return
| type | desc |
| String | 消息目的地 |
| Method |
| public String getMessageId() |
| 获取消息的Id。 |
Return
| type | desc |
| String | 消息的Id |
| Method |
| public String getMessageType() |
| 获取消息的类型。 |
Return
| type | desc |
| String | 开发者设置的消息类型,SDK不感知 |
| Method |
| public long getSentTime() |
| 获取消息从服务端下发的时间,单位ms。 |
Return
| type | desc |
| long | 自1970年1月1日0时0分0秒起至消息从服务端下发的时间点的时间差,单位毫秒。 |
| Method |
| public int getTtl() |
| 获取消息的最大缓存时间,以秒为单位。如果是服务端下发的消息返回AndroidConfig.ttl中设置的值。 |
Return
| type | desc |
| int | 消息的最大缓存时间,单位秒 |
| Method |
| public int getOriginalUrgency() |
| 获取应用设置的消息优先级,应用通过服务端API发消息时设置的级别,对应AndroidConfig.urgency字段。 |
Return
| type | desc |
| int | 消息优先级,返回值见RemoteMessage类Constants中定义 |
| Method |
| public int getUrgency() |
| 获取Push服务端设置的消息优先级。 |
Return
| type | desc |
| int | 消息优先级,返回值见RemoteMessage类Constants中定义 |
| Method |
| public RemoteMessage.Notification getNotification() |
| 如果服务端下发消息中设置了通知数据,App调用此接口从消息中获取该通知数据。 |
Return
| type | desc |
| RemoteMessage.Notification | 通知消息实例或者null。 |
| Method |
| public Map<String, String> getDataOfMap() |
| 获取Map类型消息内容。本方法不同于getData方法,本方法直接返回Java自带Map数据类型实例或者一个空Map(null)。 |
Return
| type | desc |
| Map<String, String> | 如果开发者发送消息中data字段设置为"123",则getData()方法返回"123",本方法返回null;data字段设置为{"k", "v"},则getData()方法返回JSON格式的字符串{"k", "v"},本方法返回一个包含<k, v>的Map实例。 |
| Method |
| public String getToken() |
| 获取消息中的令牌。 |
Return
| type | desc |
| String | 令牌 |