【问题标题】:How to judge the remoteMessage type如何判断remoteMessage类型
【发布时间】:2021-10-08 08:18:41
【问题描述】:

我想知道HmsMessageService中的remoteMessage是有通知还是不通知的消息数据,如何判断它们的区别?

public class HmsService extends HmsMessageService {

  @Override
  public void onMessageReceived(RemoteMessage remoteMessage) {
    // Judge if with or without notification.
  }
}

【问题讨论】:

    标签: android push-notification huawei-mobile-services huawei-developers huawei-push-notification


    【解决方案1】:

    Push Kit 可以根据目标应用的状态(在前台或后台运行)处理消息。如果希望前台运行的应用接收通知消息或数据消息,则需要实现 onMessageReceived 方法。应用收到消息后会进行后续操作。

    更多详情可以参考this Docs。如果您有任何其他问题,请随时与我们联系。

    【讨论】:

    • onMessageReceived方法中能否判断remoteMessage是通知消息还是数据消息?
    • onMessageReceived方法用于接收数据消息,通知消息直接显示,不会触发该方法。
    • 这是否意味着从通知消息中获取数据的唯一方法是点击它?
    • 这是否意味着从通知消息中获取数据的唯一方法是点击它? – ---是的?
    猜你喜欢
    • 2022-01-22
    • 2012-03-16
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 2011-01-04
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多