【问题标题】:Push Notification to specific firebase user by Expo managed workflow通过 Expo 管理的工作流向特定的 firebase 用户推送通知
【发布时间】:2020-07-30 06:05:50
【问题描述】:

我是 react-native android 应用程序的新手。 我创建了一个 Expo 项目(托管工作流),我正在搜索如何将通知发送给我从我的 android 应用程序的选择列表中选择的 特定用户,但我只找到了如何向所有安装应用程序的人推送通知的示例。

我可以使用 expo 托管工作流向 firebase 项目中的特定用户推送通知吗?还是我只需要创建 java android 项目来做到这一点?

【问题讨论】:

    标签: android firebase react-native expo


    【解决方案1】:

    以下是流程的完成方式。您需要做的是,制作 api 将每个用户的 ExpoToken ExponentPushToken[xxxxxxxxxxxx-xxxxxxxx] 保存在数据库中,与该用户的 id Expo notification doc 相对应,可能是在登录时。 然后制作一个单独的 api 用于向特定用户发送通知。选择任何用户时,调用API并发送该用户的ID和消息(如果有),那么在后端获取该用户由ID从DB开展的ID接收。之后,只需向这个 api https://exp.host/--/api/v2/push/send 发出一个 post 请求,请求正文将是:

    {
        "to": "ExponentPushToken[xxxxxxxxxxxx-xxxxxxxx]",
        "sound": "default",
        "body": "You message"
    }
    

    更多关于这个here。当您需要为应用程序生成独立的 apk 时,您首先需要将其连接到 firebase 以进行工作。这里Using Firebase Cloud Messaging for Expo. 希望你明白了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多