【问题标题】:How open Url after Firebase message received in background在后台收到 Firebase 消息后如何打开 Url
【发布时间】:2016-06-05 11:19:22
【问题描述】:

当应用程序在后台并收到 Firebase 消息时,我想打开消息数据中的特定 URL。 例如,我在 Firebase 中放置了键值,并且我想在用户点击通知后打开谷歌网站。

key: url
value: http://google.com

我该怎么办? 提前 tnx!

【问题讨论】:

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


    【解决方案1】:

    在您的应用程序中,您可以通过以下方式在 Firebase 通知 Web 控制台中访问从 Advanced options > Custom data 发送的键/值对:

    • getIntent().getExtras() 在用户点击通知时启动的活动中。
      我建议将此添加到活动onResume() 方法中。
    • remoteMessage.getData() in FirebaseMessagingService.onMessageReceived() 如果在消息到达时应用程序已经打开。 (在这种情况下,通知不会显示,而是调用 onMessageReceived()

    【讨论】:

    • Tnx Diego,你的答案是正确的。我在 onCreate() 方法和 startActivity 中编写 getExtras() 以在浏览器中显示 url,但我想要当推送通知来自 Firebase 时不启动我的应用程序的解决方案。你有什么想法吗?
    猜你喜欢
    • 1970-01-01
    • 2021-07-09
    • 1970-01-01
    • 2017-12-29
    • 1970-01-01
    • 1970-01-01
    • 2019-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多