Cette rubrique liste et décrit les types de notifications en temps réel pour les développeurs que Google Play peut envoyer.
Encodage
Chaque publication effectuée sur un sujet Cloud Pub/Sub ne contient qu'un seul champ de données encodé en base64.
{
"message": {
"attributes": {
"key": "value"
},
"data": "eyAidmVyc2lvbiI6IHN0cmluZywgInBhY2thZ2VOYW1lIjogc3RyaW5nLCAiZXZlbnRUaW1lTWlsbGlzIjogbG9uZywgIm9uZVRpbWVQcm9kdWN0Tm90aWZpY2F0aW9uIjogT25lVGltZVByb2R1Y3ROb3RpZmljYXRpb24sICJzdWJzY3JpcHRpb25Ob3RpZmljYXRpb24iOiBTdWJzY3JpcHRpb25Ob3RpZmljYXRpb24sICJ0ZXN0Tm90aWZpY2F0aW9uIjogVGVzdE5vdGlmaWNhdGlvbiB9",
"messageId": "136969346945"
},
"subscription": "projects/myproject/subscriptions/mysubscription"
}
Après avoir décodé le champ de données encodé en base64, DeveloperNotification
contient les champs suivants :
{
"version": string,
"packageName": string,
"eventTimeMillis": long,
"oneTimeProductNotification": OneTimeProductNotification,
"subscriptionNotification": SubscriptionNotification,
"testNotification": TestNotification
}
Ces champs sont décrits dans le tableau suivant.
Nom de la propriété | Valeur | Description |
version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. |
packageName | string | Nom de package de l'application auquel cette notification se rapporte (par exemple, "com.exemple.XXX"). |
eventTimeMillis | long | Horodatage de l'événement (en millisecondes à partir de la date initiale de référence du système d'exploitation). |
subscriptionNotification | SubscriptionNotification | Si ce champ est présent, cette notification est liée à un abonnement. Ce champ contient des informations supplémentaires sur l'abonnement. Notez que ce champ, testNotification et oneTimeProductNotification s'excluent mutuellement. |
oneTimeProductNotification | OneTimeProductNotification | Si ce champ est présent, cette notification est associée à un achat ponctuel, et ce champ contient des informations supplémentaires concernant l'achat. Notez que ce champ, testNotification et subscriptionProductNotification s'excluent mutuellement. |
testNotification | TestNotification | Si ce champ est présent, cette notification est liée à une publication test. Elle n'est envoyée que via la Google Play Console. Notez que ce champ, subscriptionNotification et oneTimeProductNotification s'excluent mutuellement. |
SubscriptionNotification
SubscriptionNotification
contient les champs suivants :
{
"version": string,
"notificationType": int,
"purchaseToken": string,
"subscriptionId": string
}
Nom de la propriété | Valeur | Description |
version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. |
notificationType | int | Le type de notification d'un abonnemment peut avoir les valeurs suivantes :
|
purchaseToken | string | Jeton fourni à l'appareil de l'utilisateur lors de la souscription de l'abonnement. |
subscriptionId | string | ID produit de l'abonnement acheté (par exemple, "mensuel001"). |
Exemple
Voici un exemple de notification concernant un nouvel abonnement :
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"subscriptionNotification":
{
"version":"1.0",
"notificationType":4,
"purchaseToken":"PURCHASE_TOKEN",
"subscriptionId":"monthly001"
}
}
OneTimeProductNotification
OneTimeProductNotification
contient les champs suivants :
{
"version": string,
"notificationType": int,
"purchaseToken": string,
"sku": string
}
Nom de la propriété | Valeur | Description |
version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. |
notificationType | int | Type de notification. Les valeurs suivantes sont possibles :
|
purchaseToken | string | Jeton fourni à l'appareil de l'utilisateur lors de l'achat. |
sku | string | ID du produit ponctuel acheté (par exemple, "épée_001") |
Exemple
Voici un exemple de notification concernant un nouvel achat ponctuel :
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"oneTimeProductNotification":
{
"version":"1.0",
"notificationType":1,
"purchaseToken":"PURCHASE_TOKEN",
"sku":"my.sku"
}
}
TestNotification
TestNotification
contient les champs suivants :
{
"version": string
}
Nom de la propriété | Valeur | Description |
version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. |
Exemple
Voici un exemple de notification test :
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503350156918",
"testNotification":
{
"version":"1.0"
}
}