【问题标题】:how to show firebase notification message in Layout如何在布局中显示 Firebase 通知消息
【发布时间】:2019-10-11 13:35:37
【问题描述】:

我想显示由 firebase 数据库管理员使用 firebase 消息服务发送的消息。消息由文字和图片组成。 喜欢这个 我对此进行了很多搜索,但找不到任何方法来做到这一点。所有可用的方法仅适用于短信。你能告诉我这个问题的解决方案吗

【问题讨论】:

    标签: android firebase android-layout layout firebase-cloud-messaging


    【解决方案1】:

    如果您使用 FirebaseMessagingService,则方法 onMessageReceived(remoteMessage: RemoteMessage?) 有一个 RemoteMessage 实例。

    RemoteMessage 有一个通知字段。

    通知有一个 imageUrl 字段。

    这样您就可以传输 imageUrl。 见:https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/RemoteMessage.Notification.html#getImageUrl()

    【讨论】:

      【解决方案2】:

      因为您想要的不仅仅是简单的通知,
      最好的办法是发送data message

      然后在应用程序中,您可以使用此内容并以您想要的方式呈现给用户。

      【讨论】:

        猜你喜欢
        • 2018-01-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-29
        • 1970-01-01
        • 2017-08-21
        相关资源
        最近更新 更多