android - 如何测试订阅的 Google Play 实时通知?
问题描述
我正在尝试在我的应用中实现应用内订阅。所以,首先我设置了实时通知。但问题是我无法测试它们的应用内订阅。谁能帮我这个?让我描述一下我所拥有的。
- 我创建了主题
- 在该主题中创建订阅
- 在订阅中添加了端点
- 在服务和 API 部分的 play.google.com 中添加了主题名称
- 在我的服务器上添加了端点,所以我可以接收请求
当我点击 SEND TEST NOTIFICATION 按钮时,我可以成功接收请求,但问题是请求没有任何值,如此处所述。
https://developer.android.com/google/play/billing/realtime_developer_notifications
根据链接,
Each publish made to a Pub/Sub topic contains a single base64-encoded DeveloperNotification with the following fields:
{
"version": string,
"packageName": string
"eventTimeMillis": long
"oneTimeProductNotification": OneTimeProductNotification
"subscriptionNotification": SubscriptionNotification
"testNotification": TestNotification
}
和
A TestNotification contains the following fields:
{
"version": string
}
所以我的问题是,如何测试这个 Json?我的意思是为什么请求没有值?
谢谢。
解决方案
对不起大家。我发现了问题。我试图以错误的方式获取这些字段。由于我的服务器技术是 PHP,我试图从 $_POST 数组中获取,但正确的方法是
$result = file_get_contents("php://input");
推荐阅读
- python-3.x - 将 Zoom Recordings 下载到本地计算机并使用 Resumable Upload Method 将视频上传到 Google Drive
- node.js - 无法弄清楚为什么 docker compose up 没有运行我的 React JS 应用程序
- javascript - 电子表格中的最大脚本数
- ruby-on-rails - Rails:为什么我会失去关联?
- promise - 使用 Storyblok-nuxt 发送多个 .get() 请求
- javascript - 如何从具有多个对象的平面列表中设置和获取不同的状态和输入
- javascript - 当 jQuery .match() 从列表项返回部分匹配时,如何将结果限制为完全匹配?
- postgresql - 如何使用 Postgres 数据库 url 字符串传递证书路径以进行 SSL 连接
- c++ - 如何基于 UML 图在 C++ 中设计策略模式类?
- file - Makefile 模式背后的逻辑是什么?