Skip to content

Commit 5dc968d

Browse files
committed
README update
1 parent 9654f4d commit 5dc968d

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This is the React Native SDK of Adjust™. You can read more about Adjust™ at
2525
* [Callback parameters](#callback-parameters)
2626
* [Partner parameters](#partner-parameters)
2727
* [Callback identifier](#callback-id)
28+
* [Subscription tracking](#subscription-tracking)
2829
* [Session parameters](#session-parameters)
2930
* [Session callback parameters](#session-callback-parameters)
3031
* [Session partner parameters](#session-partner-parameters)
@@ -387,6 +388,89 @@ adjustEvent.setCallbackId("Your-Custom-Id");
387388
Adjust.trackEvent(adjustEvent);
388389
```
389390

391+
### <a id="subscription-tracking"></a>Subscription tracking
392+
393+
**Note**: This feature is only available in the SDK v4.22.0 and above.
394+
395+
You can track App Store and Play Store subscriptions and verify their validity with the Adjust SDK. After a subscription has been successfully purchased, make the following call to the Adjust SDK:
396+
397+
**For App Store subscription:**
398+
399+
```js
400+
var subscription = new AdjustAppStoreSubscription(price, currency, transactionId, receipt);
401+
subscription.setTransactionDate(transactionDate);
402+
subscription.setSalesRegion(salesRegion);
403+
404+
Adjust.trackAppStoreSubscription(subscription);
405+
```
406+
407+
**For Play Store subscription:**
408+
409+
```js
410+
var subscription = new AdjustPlayStoreSubscription(price, currency, sku, orderId, signature, purchaseToken);
411+
subscription.setPurchaseTime(purchaseTime);
412+
413+
Adjust.trackPlayStoreSubscription(subscription);
414+
```
415+
416+
Subscription tracking parameters for App Store subscription:
417+
418+
- [price](https://developer.apple.com/documentation/storekit/skproduct/1506094-price?language=objc)
419+
- currency (you need to pass [currencyCode](https://developer.apple.com/documentation/foundation/nslocale/1642836-currencycode?language=objc) of the [priceLocale](https://developer.apple.com/documentation/storekit/skproduct/1506145-pricelocale?language=objc) object)
420+
- [transactionId](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411288-transactionidentifier?language=objc)
421+
- [receipt](https://developer.apple.com/documentation/foundation/nsbundle/1407276-appstorereceipturl)
422+
- [transactionDate](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411273-transactiondate?language=objc)
423+
- salesRegion (you need to pass [countryCode](https://developer.apple.com/documentation/foundation/nslocale/1643060-countrycode?language=objc) of the [priceLocale](https://developer.apple.com/documentation/storekit/skproduct/1506145-pricelocale?language=objc) object)
424+
425+
Subscription tracking parameters for Play Store subscription:
426+
427+
- [price](https://developer.android.com/reference/com/android/billingclient/api/SkuDetails#getpriceamountmicros)
428+
- [currency](https://developer.android.com/reference/com/android/billingclient/api/SkuDetails#getpricecurrencycode)
429+
- [sku](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getsku)
430+
- [orderId](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getorderid)
431+
- [signature](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getsignature)
432+
- [purchaseToken](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getpurchasetoken)
433+
- [purchaseTime](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getpurchasetime)
434+
435+
**Note:** Subscription tracking API offered by Adjust SDK expects all parameters to be passed as `string` values. Parameters described above are the ones which API exects you to pass to subscription object prior to tracking subscription. There are various libraries which are handling in app purchases in React Native and each one of them should return information described above in some form upon successfully completed subscription purchase. You should locate where these parameters are placed in response you are getting from library you are using for in app purchases, extract those values and pass them to Adjust API as string values.
436+
437+
Just like with event tracking, you can attach callback and partner parameters to the subscription object as well:
438+
439+
**For App Store subscription:**
440+
441+
```js
442+
var subscription = new AdjustAppStoreSubscription(price, currency, transactionId, receipt);
443+
subscription.setTransactionDate(transactionDate);
444+
subscription.setSalesRegion(salesRegion);
445+
446+
// add callback parameters
447+
subscription.addCallbackParameter("key", "value");
448+
subscription.addCallbackParameter("foo", "bar");
449+
450+
// add partner parameters
451+
subscription.addPartnerParameter("key", "value");
452+
subscription.addPartnerParameter("foo", "bar");
453+
454+
Adjust.trackAppStoreSubscription(subscription);
455+
```
456+
457+
**For Play Store subscription:**
458+
459+
```js
460+
var subscription = new AdjustPlayStoreSubscription(price, currency, sku, orderId, signature, purchaseToken);
461+
subscription.setPurchaseTime(purchaseTime);
462+
463+
// add callback parameters
464+
subscription.addCallbackParameter("key", "value");
465+
subscription.addCallbackParameter("foo", "bar");
466+
467+
// add partner parameters
468+
subscription.addPartnerParameter("key", "value");
469+
subscription.addPartnerParameter("foo", "bar");
470+
471+
Adjust.trackPlayStoreSubscription(subscription);
472+
```
473+
390474
### <a id="session-parameters"></a>Session parameters
391475

392476
Some parameters are saved to be sent in every event and session of the Adjust SDK. Once you have added any of these parameters, you don't need to add them every time, since they will be saved locally. If you add the same parameter twice, there will be no effect.

0 commit comments

Comments
 (0)