This topic lists and describes the types of Real-time developer notifications that you can receive from Google Play.
Encoding
Each publish made to a Cloud Pub/Sub topic contains a single base64-encoded data field.
{
"message": {
"attributes": {
"key": "value"
},
"data": "eyAidmVyc2lvbiI6IHN0cmluZywgInBhY2thZ2VOYW1lIjogc3RyaW5nLCAiZXZlbnRUaW1lTWlsbGlzIjogbG9uZywgIm9uZVRpbWVQcm9kdWN0Tm90aWZpY2F0aW9uIjogT25lVGltZVByb2R1Y3ROb3RpZmljYXRpb24sICJzdWJzY3JpcHRpb25Ob3RpZmljYXRpb24iOiBTdWJzY3JpcHRpb25Ob3RpZmljYXRpb24sICJ0ZXN0Tm90aWZpY2F0aW9uIjogVGVzdE5vdGlmaWNhdGlvbiB9",
"messageId": "136969346945"
},
"subscription": "projects/myproject/subscriptions/mysubscription"
}
After you decode the base64-encoded data field, the DeveloperNotification
contains the following fields:
{
"version": string,
"packageName": string,
"eventTimeMillis": long,
"oneTimeProductNotification": OneTimeProductNotification,
"subscriptionNotification": SubscriptionNotification,
"testNotification": TestNotification
}
These fields are described in the following table.
Property name | Value | Description |
version | string | The version of this notification. Initially, this is "1.0". This version is distinct from other version fields. |
packageName | string | The package name of the application that this notification relates to (for example, `com.some.thing`). |
eventTimeMillis | long | The timestamp when the event occurred, in milliseconds since the Epoch. |
subscriptionNotification | SubscriptionNotification | If this field is present, then this notification is related to a subscription, and this field contains additional information related to the subscription. Note that this field is mutually exclusive with testNotification and oneTimeProductNotification. |
oneTimeProductNotification | OneTimeProductNotification | If this field is present, then this notification is related to a one-time purchase, and this field contains additional information related to the purchase. Note that this field is mutually exclusive with testNotification and subscriptionProductNotification. |
testNotification | TestNotification | If this field is present, then this notification is related to a test publish. These are sent only through the Google Play Developer Console. Note that this field is mutually exclusive with subscriptionNotification and oneTimeProductNotification. |
SubscriptionNotification
A SubscriptionNotification
contains the following fields:
{
"version": string,
"notificationType": int,
"purchaseToken": string,
"subscriptionId": string
}
Property name | Value | Description |
version | string | The version of this notification. Initially, this is "1.0". This version is distinct from other version fields. |
notificationType | int | The notificationType for a subscription can have the following values:
|
purchaseToken | string | The token provided to the user's device when the subscription was purchased. |
subscriptionId | string | The purchased subscription's product ID (for example, "monthly001"). |
Example
Here's an example of a notification for a new subscription purchase:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"subscriptionNotification":
{
"version":"1.0",
"notificationType":4,
"purchaseToken":"PURCHASE_TOKEN",
"subscriptionId":"monthly001"
}
}
OneTimeProductNotification
A OneTimeProductNotification
contains the following fields:
{
"version": string,
"notificationType": int,
"purchaseToken": string,
"sku": string
}
Property Name | Value | Description |
version | string | The version of this notification. Initially, this will be "1.0". This version is distinct from other version fields. |
notificationType | int | The type of notification. It can have the following values:
|
purchaseToken | string | The token provided to the user’s device when purchase was made. |
sku | string | The purchased one-time product ID (for example, "sword_001") |
Example
Here's an example of a notification for a new one-time purchase:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"oneTimeProductNotification":
{
"version":"1.0",
"notificationType":1,
"purchaseToken":"PURCHASE_TOKEN",
"sku":"my.sku"
}
}
TestNotification
A TestNotification
contains the following fields:
{
"version": string
}
Property name | Value | Description |
version | string | The version of this notification. Initially, this is "1.0". This version is distinct from other version fields. |
Example
Here's an example of a test notification:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503350156918",
"testNotification":
{
"version":"1.0"
}
}