firebase - 如何通过 Pub/Sub 将 Google Play 实时开发者通知连接到 Firebase 云功能?

标签 firebase google-play google-cloud-functions google-cloud-pubsub google-play-console

我的新移动应用程序处于开发的最后阶段,但似乎无法找到允许 Google Play 实时开发人员通知通过推荐的 Google Pub/Sub 方法与 Firebase 云功能通信的方法。

预期的有效载荷流应如下所示:

用户通过 Play 商店购买订阅 > Play 商店向 Pub/Sub 发送 R-T 开发通知 > Pub/Sub 将消息发送到 Firebase 云功能 > 云函数与有效负载一起运行 .

我目前以类似的方式设置了 Apple Developer webhook,它将收据有效负载 webhook 到我设置的 iOS 云功能。

在发布/订阅设置阶段,发布/订阅页面要求验证云功能URL,我不能这样做,因为我不是云功能域的真正站长,因此在“添加实时开发人员谷歌提供的通知”文档。

有没有办法将 RT 通知发送到 Pub/Sub 云功能或 HTTPS 云功能,绕过 Google Pub/Sub 并直接转到 webhook 或其他方式来完成上述流程?

最终目的是提供一种方法来确保所进行的购买实际上是有效的购买,而不是某人拦截客户端 > 服务器 webhook 并自行提交的伪造请求。

最佳答案

创建新主题后您不要必须创建手动 发布/订阅订阅,如 documentation 中所述.

要使其与 firebase 一起使用,您必须部署一个新的云功能,如下所示:

exports.YOUR_FUNCTION_NAME = functions.pubsub.topic('YOUR_TOPIC_NAME').onPublish((message) => {

  // Decode the PubSub Message body.
  const messageBody = message.data ? Buffer.from(message.data, 'base64').toString() : null;

  // Print the message in the logs.
  console.log(`Hello ${messageBody || 'World'}!`);
  return null;


});

请注意,您需要替换 YOUR_FUNCTION_NAME 和 YOUR_TOPIC_NAME。

部署此功能时完成 ,你最终会在 subscription list 中找到该函数.
此时可以编辑的参数自动 创建订阅,你会发现 url 端点 已经填充了一个内部网址。

在这里你可以找到一个例子:how to setup a PubSub triggered Cloud Function using the Firebase SDK for Cloud Functions.

关于firebase - 如何通过 Pub/Sub 将 Google Play 实时开发者通知连接到 Firebase 云功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58000608/

相关文章:

android - 程序类型已经存在 : com. google.android.gms.common.api.zzf

firebase - Angular Dart firebase电子邮件和密码身份验证

cordova - 在Google Play商店上发布应用程序升级

google-play - 我可以使用我在美国的亲戚作为代理人在安卓市场上销售我的安卓应用程序吗?

firebase - 使用 Firebase Cloud Functions 中的 Slack APIdialog_open

ios - Firebase 查询 - 查找包含字符串的子项目

Firebase 部署错误 "Error: Functions did not deploy properly."

android - 在不上传 APK 的情况下测试 google play 服务

firebase - Firebase Cloud Functions ESLint 最近有变化吗?

Firebase 函数记录器日志未定义