最后更新于
July 15, 2022
Before you get started, you'll need to:
If you're setting up PIA for Google Play games, you'll also need to add your app's public key to a field on the game's App Settings page:
Here's how to find your public key:
You'll find a sample project, InAppPurchase, that illustrates Google Play PIA functionality in our latest Android SDK package.
Our InAppPurchase sample project includes a GoogleIAPTracking.java file you can use to see PIA in action. Note that there are several ways to handle the IAP flow; below are highlights from the method our sample project uses:
1) Set up item(s) with SKU(s) in Google Play Developer Console and note SKU(s):
2) Add SKU(s) to project (in strings.xml)
3) In onCreate, set up purchase flow for IAPs (one method is shown in line 54 of GoogleIAPTracking.java):
4) Use Google API to make purchase (line 79):
5) After successful purchase, store purchase information in inventory, as shown in sample app (line 99). Once inventory stores information successfully, send information to the Chartboost SDK via the trackInAppGooglePlayPurchaseEvent class (line 127):
6) Lastly, you can use a proxy service like Charles to verify that purchase data successfully reached our api/post-install-event/ endpoint. (Note: Even before this, null/empty purchase information will be flagged as such by errors in the log.)