簡體   English   中英

如何通過 Pub/Sub 將 Google Play 實時開發者通知連接到 Firebase Cloud Function?

[英]How to Connect Google Play Real-Time Developer Notifications to Firebase Cloud Function via Pub/Sub?

我的新移動應用程序正處於開發的最后階段,但似乎無法找到一種方法讓 Google Play 實時開發人員通知通過推薦的 Google Pub/Sub 方法與 firebase 雲 function 進行通信。

預期的有效載荷流應為 go,如下所示:

用戶通過 Play 商店購買訂閱> Play 商店向 Pub/Sub 發送 RT Dev Notification > Pub/Sub 將消息發送到 firebase 雲 function >雲 ZC1C425268E68385D1AB5074C17A94 運行

我目前以類似的方式設置了 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谷歌提供的通知文檔。

有沒有辦法將 RT 通知發送到 Pub/Sub 雲 function 或 HTTPS 雲 function 繞過上面的 Google 流程並直接通過 Google Pub/Sub

最終目的是提供一種方法來確保所進行的購買實際上是有效的購買,而不是由攔截客戶端 > 服務器 webhook 並自行提交的人發出的偽造請求。

創建新主題后,您不必按照文檔中的說明手動創建 Pub/Sub 訂閱。

要使其與 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;


});

請注意,您需要替換 YOUR_FUNCTION_NAME 和 YOUR_TOPIC_NAME。

當這個 function 部署完成后,您最終會在 訂閱列表中找到 function。 此時,您可以編輯自動創建的訂閱的參數,您會發現url 端點已經填充了內部 url。

在這里您可以找到一個示例: 如何使用 Firebase SDK 為 Cloud Functions 設置 PubSub 觸發的 Cloud Function。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM