Google Play
SDK integration
Prerequisites:
Native SDK
DTDAnalytics 2.5.0 and higher
Unity
DTDAnalytics 3.9.0
DTDAutoPurchases 3.9.0
To initialize the service, it is necessary to call the startAutoTracking
method of the DTDPurchases
interface. The method call should be made after SDK initialization call:
Subscription restore
SDK will automatically restore the list of previously purchased subscriptions at the first launch of the autotracking service. No additional integration is required.
Settings in Google Cloud Platform Console
If you have already activated the Google Play Android Developer API and set up a service account to work with devtodev, you can skip this section.
Google Play Android Developer API
Go to Google Cloud Console under your Google account. Select the project for which you want to configure Google Play Developer API. Then go to the APIs and services section.
Go to the Library section.
Find the Google Play Developer API section.
Press the ENABLE button.
Service account
To create a service account, click the link https://console.cloud.google.com/apis/credentials/serviceaccountkey
If you already have selected an active project, then skip the project selection block below.
Select the project that you will link to the service account and for which you will collect subscription data later. If the project is not listed, create it.
In the list of available service keys, click on the Create service account link.
In the provided free form, fill in the Service account name field, the Service Account ID field will be filled in automatically (use the screenshot below as an example) and click CREATE AND CONTINUE button.
Steps 2 and 3 are not needed, just click the Done button at the end of the form.
After creating a service account, you will be returned to the list of available accounts. Select the created account and open the KEYS tab, click the ADD KEY button, and then select the JSON option in the pop-up window. Confirm your choice by clicking the Create button. The generated private key file will be automatically downloaded. You will need to upload this key into the analysis connection forms. This will be explained in the following sections.
Go to the IAM section in the Permissions tab and click GRANT ACCESS to add roles to the service account in New principals section. In the appeared form, enter the service account address and give it the Pub/Sub Subscriber role. If you don’t have this role, you need to activate the Pub/Sub service in the Cloud Platform. Save the changes.
Pub/Sub service
Go to the list of topics in the Pub/Sub service https://console.cloud.google.com/cloudpubsub/topic/list
Select the project on which you want to collect subscription data if it is not selected yet, then click the CREATE TOPIC link and create a topic.
To do this, fill in the Topic ID (use the screenshot below as an example), disable Add a default subscription option and confirm the topic creation.
As shown in the example below, select from the pop-up menu View permissions.
Click on the button ADD PRINCIPAL.
Add the service account
google-play-developer-notifications@system.gserviceaccount.com
, and grant it the role of Pub/Sub Publisher. Save the changes.After that, open the list of subscriptions and click CREATE SUBSCRIPTION.
In the appeared form, specify the Subscription ID in the field below Select a Cloud Pub/Sub topic specify the topic you’ve just created, in the Delivery type choose Push and in the Endpoint URL field insert the link obtained from the devtodev subscription integration window that described on the next session (Settings on devtodev side). All other parameters remain unchanged. Save the changes.
To get Endpoint URL go to devtodev, select the same app and open the app settings (Settings -> Payments integration -> Subscriptions). Click on the button Integrate.
In the next form copy the Endpoint URL.
Settings on devtodev side
Go to Settings → Payments integration → IAP auto tracking → Integrate.
Fill in the integration form with the data obtained earlier:
Android App ID
Upload the Private key file obtained in Step 1.
Save changes
When the integration is complete, the status will change to Active
Settings in Google Play Console
Service account and User permissions
To set up user permission, you need to log into your Google Play Console account and invite your previously created service account.
Sign into the Google Play Developer Console.
In the Users and permissions section, you can add users and manage their permissions.
Click Users and permissions.
Click the Invite new users button.
Add Service Account
Put an email address for your service account in the email address field and grant the necessary rights to perform actions. How to create a service account see Step 1. Service account.
In the Permissions section select the apps this service account has access to. Click Apply. Grant permissions to individual apps, or use account permissions to grant access to all apps in your developer account.
You must grant the following permissions:
View app information
View app quality information
View financial data
Click on Apply button.
Please note that the specified settings may not work immediately!
After creating a subscription in the Pub/Sub service, you'll need to register the created topic as a target for RTDN (Real-time developer notifications). To do this, go to the app’s Monetise with Play → Monetisation setup section and enter the full name of the topic in the Topic name field. After that, send a test notification using the link below. If everything is configured correctly, then the test notification will change the integration status of the Subscriptions in devtodev to Active.
Last updated
Was this helpful?