本主題列出並描述您可從 Google Play 收到的即時開發人員通知類型。
編碼
每次發布至 Cloud Pub/Sub 主題的發布內容都會包含一個 Base64 編碼的資料欄位。
{
"message": {
"attributes": {
"key": "value"
},
"data": "eyAidmVyc2lvbiI6IHN0cmluZywgInBhY2thZ2VOYW1lIjogc3RyaW5nLCAiZXZlbnRUaW1lTWlsbGlzIjogbG9uZywgIm9uZVRpbWVQcm9kdWN0Tm90aWZpY2F0aW9uIjogT25lVGltZVByb2R1Y3ROb3RpZmljYXRpb24sICJzdWJzY3JpcHRpb25Ob3RpZmljYXRpb24iOiBTdWJzY3JpcHRpb25Ob3RpZmljYXRpb24sICJ0ZXN0Tm90aWZpY2F0aW9uIjogVGVzdE5vdGlmaWNhdGlvbiB9",
"messageId": "136969346945"
},
"subscription": "projects/myproject/subscriptions/mysubscription"
}
將 Base64 編碼的資料欄位解碼後,DeveloperNotification
會包含以下欄位:
{
"version": string,
"packageName": string,
"eventTimeMillis": long,
"oneTimeProductNotification": OneTimeProductNotification,
"subscriptionNotification": SubscriptionNotification,
"testNotification": TestNotification
}
下表提供這些欄位的說明。
屬性名稱 | 值 | 說明 |
version | string | 這則通知的版本。一開始會是「1.0」。此版本與其他版本欄位不同。 |
packageName | string | 與這則通知相關的應用程式套件名稱 (例如「com.some.thing」)。 |
eventTimeMillis | long | 事件發生時的時間戳記 (以從 Epoch 紀元時間算起的毫秒數表示)。 |
subscriptionNotification | SubscriptionNotification | 如有這個欄位,則這則通知與訂閱相關,且這個欄位含有與訂閱相關的其他資訊。請注意,這個欄位與 testNotification 和 oneTimeProductNotification 互斥。 |
oneTimeProductNotification | OneTimeProductNotification | 如果有這個欄位,則這則通知與一次性消費相關,且這個欄位含有與消費相關的額外資訊。請注意,這個欄位與 testNotification 和 subscriptionProductNotification 互斥。 |
testNotification | TestNotification | 如果有這個欄位,則這則通知與測試發布相關。這些內容只會透過 Google Play 管理中心傳送。請注意,這個欄位與 subscriptionNotification 和 oneTimeProductNotification 互斥。 |
SubscriptionNotification
SubscriptionNotification
包含下列欄位:
{
"version": string,
"notificationType": int,
"purchaseToken": string,
"subscriptionId": string
}
屬性名稱 | 值 | 說明 |
version | string | 這則通知的版本。一開始會是「1.0」。此版本與其他版本欄位不同。 |
notificationType | int | 訂閱項目的 notificationType 可能具有下列值:
|
purchaseToken | string | 購買訂閱項目時提供給使用者裝置的權杖。 |
subscriptionId | string | 所購買訂閱項目的產品 ID (例如「monthly001」)。 |
範例
以下是新的訂閱項目購買交易的通知範例:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"subscriptionNotification":
{
"version":"1.0",
"notificationType":4,
"purchaseToken":"PURCHASE_TOKEN",
"subscriptionId":"monthly001"
}
}
OneTimeProductNotification
OneTimeProductNotification
包含下列欄位:
{
"version": string,
"notificationType": int,
"purchaseToken": string,
"sku": string
}
屬性名稱 | 值 | 說明 |
version | string | 這則通知的版本。一開始會是「1.0」。此版本與其他版本欄位不同。 |
notificationType | int | 通知類型,可能具有下列值:
|
purchaseToken | string | 購買產品時提供給使用者裝置的權杖。 |
sku | string | 所購買一次性產品的 ID (例如「sword_001」) |
範例
以下是新的一次性消費的通知範例:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503349566168",
"oneTimeProductNotification":
{
"version":"1.0",
"notificationType":1,
"purchaseToken":"PURCHASE_TOKEN",
"sku":"my.sku"
}
}
TestNotification
TestNotification
包含下列欄位:
{
"version": string
}
屬性名稱 | 值 | 說明 |
version | string | 這則通知的版本。一開始會是「1.0」。此版本與其他版本欄位不同。 |
範例
以下是測試通知範例:
{
"version":"1.0",
"packageName":"com.some.thing",
"eventTimeMillis":"1503350156918",
"testNotification":
{
"version":"1.0"
}
}