【问题标题】:how to send push notification when user posts a new message in firebase?当用户在firebase中发布新消息时如何发送推送通知?
【发布时间】:2017-07-06 03:30:02
【问题描述】:

我正在使用 Ionic 和 firebase。我将用户的所有帖子存储在('/posts')中。我遇到了这个插件。 https://github.com/fechanique/cordova-plugin-fcm。在这部分,它可以选择订阅主题。

FCMPlugin.subscribeToTopic('topicExample');

但我认为这不适用于数据库。我如何订阅我的帖子('/post')。发送推送通知?

【问题讨论】:

    标签: cordova firebase firebase-realtime-database cordova-plugin-fcm


    【解决方案1】:

    自从我上次使用 firebase 以来已经有一段时间了,但如果我没记错的话,你不能通过更改 db 来直接发送推送通知。为此,您需要使用 firebase 函数。

    基本上,您要做的就是编写一个 firebase 函数,当您写入 /post 列表时会触发该函数。然后,您可以在该函数中发送通知。

    这里描述了整个过程,包括代码示例: https://aaronczichon.de/2017/03/13/firebase-cloud-functions/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-31
      • 1970-01-01
      • 1970-01-01
      • 2017-10-04
      • 2019-03-18
      • 2021-09-02
      • 1970-01-01
      • 2020-06-05
      相关资源
      最近更新 更多