Skip to content

Commit 06f0e47

Browse files
committed
docs: update README
1 parent bf6e9e6 commit 06f0e47

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,51 @@ The following parameters are also included with the signal:
478478
| `TelemetryDeck.Purchase.offerID` | The specific offer identifier for subscription products or customized pricing |
479479

480480

481+
### Google Play
482+
483+
When integrating with Google Play Billing Library, you can adopt the TelemetryDeck SDK with Google Play Services in order to let us determine the exact purchase parameters.
484+
485+
1. Add the following package as a dependency to your app:
486+
487+
```kotlin
488+
// `build.gradle.kts`
489+
dependencies {
490+
implementation("com.telemetrydeck:kotlin-sdk-google-services:6.2.0")
491+
}
492+
```
493+
494+
2. You can now use the `purchaseCompleted` function optimized for Google Play Billing:
495+
496+
```kotlin
497+
fun purchaseHandlerInYourApp(
498+
billingConfig: BillingConfig,
499+
purchase: Purchase,
500+
productDetails: ProductDetails
501+
) {
502+
TelemetryDeck.purchaseCompleted(
503+
billingConfig = billingConfig,
504+
purchase = purchase,
505+
productDetails = productDetails
506+
)
507+
}
508+
```
509+
510+
By default, this method assumes the purchase is a `PAID_PURCHASE`. To determine if the user is converting or starting a trial, you will have to implement your own [server-side validation](https://developer.android.com/google/play/billing/integrate) and inspect the `paymentState` of a subscription.
511+
512+
To make it easier to get started, the TelemetryDeck SDK offers a helper method which attempts to guess the purchase origin based on locally available data, so you could:
513+
514+
```kotlin
515+
TelemetryDeck.purchaseCompleted(
516+
billingConfig = billingConfig,
517+
purchase = purchase,
518+
productDetails = productDetails,
519+
purchaseOrigin = purchase.toTelemetryDeckPurchaseEvent(setOf("TRIAL_SKU"))
520+
)
521+
```
522+
523+
Note that this approach is not exact and comes with a certain number of limitations, please check the doc notes on `com.telemetrydeck.sdk.googleservices.toTelemetryDeckPurchaseEvent` for more details.
524+
525+
481526
## Custom Telemetry
482527

483528
Another way to send signals is to implement a custom `TelemetryDeckProvider`.

0 commit comments

Comments
 (0)