[英]How to Connect Google Play Real-Time Developer Notifications to Firebase Cloud Function via Pub/Sub?
I'm in the final stages of development for my new mobile app, but can't seem to find a way to allow Google Play Real-Time Developer Notifications to communicate to a firebase cloud function via the recommended Google Pub/Sub method.我的新移动应用程序正处于开发的最后阶段,但似乎无法找到一种方法让 Google Play 实时开发人员通知通过推荐的 Google Pub/Sub 方法与 firebase 云 function 进行通信。
The expected payload flow should go as follows:预期的有效载荷流应为 go,如下所示:
User Purchases Subscription via Play Store > Play Store sends RT Dev Notification to Pub/Sub > Pub/Sub sends message across to firebase cloud function > Cloud function runs with payload .用户通过 Play 商店购买订阅> Play 商店向 Pub/Sub 发送 RT Dev Notification > Pub/Sub 将消息发送到 firebase 云 function >云 ZC1C425268E68385D1AB5074C17A94 运行。
I currently have an Apple Developer webhook set-up in a similar way, which webhooks a receipt payload to an iOS cloud function I have setup.我目前以类似的方式设置了 Apple Developer webhook,它将收据有效负载 webhook 到 iOS 云 function 我已经设置。
During the pub/sub setup phase, the Pub/Sub page asks to verify the cloud function URL, which I cannot do as I am not the true webmaster of cloud function domain, hence halting me about halfway down the 'Add real-time developer notification' docs that google supplies. During the pub/sub setup phase, the Pub/Sub page asks to verify the cloud function URL, which I cannot do as I am not the true webmaster of cloud function domain, hence halting me about halfway down the 'Add real-time developer谷歌提供的通知文档。
Is there a way to get the RT notification to either a Pub/Sub cloud function or a HTTPS cloud function bypassing the google Pub/Sub and going directly to the webhook or another way to complete the flow above?有没有办法将 RT 通知发送到 Pub/Sub 云 function 或 HTTPS 云 function 绕过上面的 Google 流程并直接通过 Google Pub/Sub
The ultimate aim is to provide a way to ensure the purchase made is actually a valid purchase, and not a forged request made by someone intercepting the client > server webhook and submitting one of their own accord.最终目的是提供一种方法来确保所进行的购买实际上是有效的购买,而不是由拦截客户端 > 服务器 webhook 并自行提交的人发出的伪造请求。
After creating the new topic you DO NOT have to create manually a Pub/Sub subscription as explained in the documentation .创建新主题后,您不必按照文档中的说明手动创建 Pub/Sub 订阅。
To make it work with firebase you have to deploy a new cloud function like this:要使其与 firebase 一起使用,您必须像这样部署新的云 function:
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;
});
Please note that you need to replace YOUR_FUNCTION_NAME and YOUR_TOPIC_NAME.请注意,您需要替换 YOUR_FUNCTION_NAME 和 YOUR_TOPIC_NAME。
When the deploy of this function finish , you will finally find the function in the subscription list .当这个 function 部署完成后,您最终会在 订阅列表中找到 function。 At this point, you can edit the params of the automatically created subscription, and you will find the url endpoint already filled with an internal url.
此时,您可以编辑自动创建的订阅的参数,您会发现url 端点已经填充了内部 url。
Here you can find an example: how to setup a PubSub triggered Cloud Function using the Firebase SDK for Cloud Functions.在这里您可以找到一个示例: 如何使用 Firebase SDK 为 Cloud Functions 设置 PubSub 触发的 Cloud Function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.