Google Play RTDN
Overview
Google Play RTDN leverage the use of Google Cloud Pub/Sub to send real-time notifications that allows you to react immediately to changes in the subscription state, avoiding the need to poll the API.
To receive notifications, you need to create a backend server to consume the messages sent to your topic. This is provided out of the box by LIAP.
To use Cloud Pub/Sub, you must have a Google Cloud Platform project with Cloud Pub/Sub enabled. Check the Quickstart guide for more information.
Setup
The following steps are required to receive notifications:
- Create a topic.
- Create Pub/Sub a subscription.
- Grant the service account permission to publish messages to the topic.
- Enable Real-time developer notifications for your app.
Create a topic
To create a topic, you can use the Guide me feature provided by Google that guides you through the process of creating a topic.
Or you can use the Google Cloud Console, which is a simple interface for managing topics.
Then Click on the Create a topic button. In the Topic ID field, enter a unique ID for your topic, then click Save.
Create a Pub/Sub subscription
To receive messages from the topic, you need to create a subscription to that topic. To create a subscription, do the following:
- Display the menu for the topic you just created.
- Click on the Create a subscription button.
- Type the name of the subscription.
- Choose Push to endpoint as the delivery Type.
- Enter the URL of the backend server you created in the Endpoint URL.
- Click on the Create button.
Grant publish rights on your topic
Google Pub/Sub requires that you grant Google Play the permission to publish notifications to your topic. To do this:
- Find your topic in the Google Cloud Console.
- Open the permissions details.
On the right side of the page, click on the Add Principal button.
Add the service account
google-play-developer-notifications@system.gserviceaccount.com
,
and grant it the role of Pub/Sub Publisher.
- Click Save to complete the topic set up.
Enable Real-time developer notifications for your app
To enable real-time developer notifications for your app, do the following:
- Go to the Google Play Console.
- Select your app.
- Go the Monetize > Monetization tab.
- Scroll down to the Real-time developer notifications section.
- In the Topic name field, enter the name of the topic you created. It
should be in the format
projects/{project_id}/topics/{topic_name}
. - Click Save changes.
Sending a Test Message requires a deployed endpoint to receive the message, otherwise the message will keep trying to be sent.
Test messages are logged by LIAP out of the box, so you can see the messages in the logs.