Search code examples
androidgoogle-playin-app-purchasein-app-billingin-app-subscription

How to test Google Play Real Time Notifications for Subscriptions?


I'm trying to implement in-app subscriptions in my app. So ,first I set upped the real time notifications. But the problem is that I can't test them for in-app subscriptions. Can anyone help me with this? Let me describe what I have.

  1. I created the topic
  2. Created the subscription in that topic
  3. Added the endpoint in the subscription
  4. Added topic name in the play.google.com in the Services and APIs section
  5. Added the endpoint on my server, so I can receive the requests

When I hit the SEND TEST NOTIFICATION button, I can successfully receive the request, but the problem is that the request has no any values, as described here.

https://developer.android.com/google/play/billing/realtime_developer_notifications

According to link,

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
}

and

A TestNotification contains the following fields:
{
  "version": string
}

So my question is , how can test this Json? I mean why the request has no values ?

Thanks.


Solution

  • Sorry Guys. I found the problem. I was trying to get the fields in the wrong way. As my server technology is PHP,I was trying to get from $_POST array, but the right way is

    $result = file_get_contents("php://input");