Skip to content

Commit 3acdf18

Browse files
authored
Merge pull request #17 from adjust/v4220
Version 4.22.0
2 parents 59a2f2a + d1188a4 commit 3acdf18

File tree

26 files changed

+635
-68
lines changed

26 files changed

+635
-68
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
### Version 4.22.0 (10th June 2020)
2+
#### Added
3+
- Added subscription tracking feature.
4+
- Added support for Huawei App Gallery install referrer.
5+
6+
#### Changed
7+
- Updated communication flow with `iAd.framework`.
8+
9+
#### Native SDKs
10+
- [[email protected]][ios_sdk_v4.22.1]
11+
- [[email protected]][android_sdk_v4.22.0]
12+
13+
---
14+
115
### Version 4.21.0 (25th March 2021)
216
#### Added
317
- Added `disableThirdPartySharing` method to `Adjust` interface to allow disabling of data sharing with third parties outside of Adjust ecosystem.
@@ -98,7 +112,9 @@
98112
[ios_sdk_v4.18.0]: https://github.com/adjust/ios_sdk/tree/v4.18.0
99113
[ios_sdk_v4.18.3]: https://github.com/adjust/ios_sdk/tree/v4.18.3
100114
[ios_sdk_v4.21.0]: https://github.com/adjust/ios_sdk/tree/v4.21.0
115+
[ios_sdk_v4.22.1]: https://github.com/adjust/ios_sdk/tree/v4.22.1
101116

102117
[android_sdk_v4.17.0]: https://github.com/adjust/android_sdk/tree/v4.17.0
103118
[android_sdk_v4.18.0]: https://github.com/adjust/android_sdk/tree/v4.18.0
104119
[android_sdk_v4.21.0]: https://github.com/adjust/android_sdk/tree/v4.21.0
120+
[android_sdk_v4.22.0]: https://github.com/adjust/android_sdk/tree/v4.22.0

README.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ This is the Flutter SDK of Adjust™. You can read more about Adjust™ at [adju
5151

5252
### Additional features
5353

54+
* [Subscription tracking](#af-subscription-tracking)
5455
* [Push token (uninstall tracking)](#af-push-token)
5556
* [Attribution callback](#af-attribution-callback)
5657
* [Session and event callbacks](#af-session-event-callbacks)
@@ -87,7 +88,7 @@ You can add Adjust SDK to your Flutter app by adding following to your `pubspec.
8788

8889
```yaml
8990
dependencies:
90-
adjust_sdk: ^4.21.0
91+
adjust_sdk: ^4.22.0
9192
```
9293
9394
Then navigate to your project in the terminal and run:
@@ -595,6 +596,109 @@ In this case, this will make the Adjust SDK not send the initial install session
595596

596597
Once you have integrated the Adjust SDK into your project, you can take advantage of the following features.
597598

599+
### <a id="af-subscription-tracking"></a>Subscription tracking
600+
601+
**Note**: This feature is only available in the SDK v4.22.0 and above.
602+
603+
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:
604+
605+
**For App Store subscription:**
606+
607+
```dart
608+
AdjustAppStoreSubscription subscription = new AdjustAppStoreSubscription(
609+
price,
610+
currency,
611+
transactionId,
612+
receipt);
613+
subscription.setTransactionDate(transactionDate);
614+
subscription.setSalesRegion(salesRegion);
615+
616+
Adjust.trackAppStoreSubscription(subscription);
617+
```
618+
619+
**For Play Store subscription:**
620+
621+
```dart
622+
AdjustPlayStoreSubscription subscription = new AdjustPlayStoreSubscription(
623+
price,
624+
currency,
625+
sku,
626+
orderId,
627+
signature,
628+
purchaseToken);
629+
subscription.setPurchaseTime(purchaseTime);
630+
631+
Adjust.trackPlayStoreSubscription(subscription);
632+
```
633+
634+
Subscription tracking parameters for App Store subscription:
635+
636+
- [price](https://developer.apple.com/documentation/storekit/skproduct/1506094-price?language=objc)
637+
- 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)
638+
- [transactionId](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411288-transactionidentifier?language=objc)
639+
- [receipt](https://developer.apple.com/documentation/foundation/nsbundle/1407276-appstorereceipturl)
640+
- [transactionDate](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411273-transactiondate?language=objc)
641+
- 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)
642+
643+
Subscription tracking parameters for Play Store subscription:
644+
645+
- [price](https://developer.android.com/reference/com/android/billingclient/api/SkuDetails#getpriceamountmicros)
646+
- [currency](https://developer.android.com/reference/com/android/billingclient/api/SkuDetails#getpricecurrencycode)
647+
- [sku](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getsku)
648+
- [orderId](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getorderid)
649+
- [signature](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getsignature)
650+
- [purchaseToken](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getpurchasetoken)
651+
- [purchaseTime](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getpurchasetime)
652+
653+
**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 Flutter 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.
654+
655+
Just like with event tracking, you can attach callback and partner parameters to the subscription object as well:
656+
657+
**For App Store subscription:**
658+
659+
```dart
660+
AdjustAppStoreSubscription subscription = new AdjustAppStoreSubscription(
661+
price,
662+
currency,
663+
transactionId,
664+
receipt);
665+
subscription.setTransactionDate(transactionDate);
666+
subscription.setSalesRegion(salesRegion);
667+
668+
// add callback parameters
669+
subscription.addCallbackParameter('key', 'value');
670+
subscription.addCallbackParameter('foo', 'bar');
671+
672+
// add partner parameters
673+
subscription.addPartnerParameter('key', 'value');
674+
subscription.addPartnerParameter('foo', 'bar');
675+
676+
Adjust.trackAppStoreSubscription(subscription);
677+
```
678+
679+
**For Play Store subscription:**
680+
681+
```dart
682+
AdjustPlayStoreSubscription subscription = new AdjustPlayStoreSubscription(
683+
price,
684+
currency,
685+
sku,
686+
orderId,
687+
signature,
688+
purchaseToken);
689+
subscription.setPurchaseTime(purchaseTime);
690+
691+
// add callback parameters
692+
subscription.addCallbackParameter('key', 'value');
693+
subscription.addCallbackParameter('foo', 'bar');
694+
695+
// add partner parameters
696+
subscription.addPartnerParameter('key', 'value');
697+
subscription.addPartnerParameter('foo', 'bar');
698+
699+
Adjust.trackPlayStoreSubscription(subscription);
700+
```
701+
598702
### <a id="af-push-token"></a>Push token (uninstall tracking)
599703

600704
Push tokens are used for Audience Builder and client callbacks, and they are required for uninstall and reinstall tracking.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.21.0
1+
4.22.0

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
}
88

99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.6.1'
10+
classpath('com.android.tools.build:gradle:4.0.0')
1111
}
1212
}
1313
rootProject.allprojects {
@@ -36,5 +36,5 @@ android {
3636
}
3737

3838
dependencies {
39-
implementation 'com.adjust.sdk:adjust-android:4.21.0'
39+
implementation 'com.adjust.sdk:adjust-android:4.22.0'
4040
}

android/src/main/java/com/adjust/sdk/flutter/AdjustSdk.java

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.adjust.sdk.AdjustEventSuccess;
2121
import com.adjust.sdk.AdjustSessionFailure;
2222
import com.adjust.sdk.AdjustSessionSuccess;
23+
import com.adjust.sdk.AdjustPlayStoreSubscription;
2324
import com.adjust.sdk.AdjustTestOptions;
2425
import com.adjust.sdk.LogLevel;
2526
import com.adjust.sdk.OnAttributionChangedListener;
@@ -143,6 +144,12 @@ public void onMethodCall(MethodCall call, final Result result) {
143144
case "trackAdRevenue":
144145
trackAdRevenue(call, result);
145146
break;
147+
case "trackAppStoreSubscription":
148+
trackAppStoreSubscription(result);
149+
break;
150+
case "trackPlayStoreSubscription":
151+
trackPlayStoreSubscription(call, result);
152+
break;
146153
case "setTestOptions":
147154
setTestOptions(call, result);
148155
break;
@@ -680,6 +687,108 @@ private void trackAdRevenue(final MethodCall call, final Result result) {
680687
result.success(null);
681688
}
682689

690+
private void trackAppStoreSubscription(final Result result) {
691+
result.error("0", "Error. No App Store subscription tracking for Android plaftorm!", null);
692+
}
693+
694+
private void trackPlayStoreSubscription(final MethodCall call, final Result result) {
695+
Map subscriptionMap = (Map) call.arguments;
696+
if (subscriptionMap == null) {
697+
return;
698+
}
699+
700+
// Price.
701+
long price = -1;
702+
if (subscriptionMap.containsKey("price")) {
703+
try {
704+
price = Long.parseLong(subscriptionMap.get("price").toString());
705+
} catch (NumberFormatException ignore) {}
706+
}
707+
708+
// Currency.
709+
String currency = null;
710+
if (subscriptionMap.containsKey("currency")) {
711+
currency = (String) subscriptionMap.get("currency");
712+
}
713+
714+
// SKU.
715+
String sku = null;
716+
if (subscriptionMap.containsKey("sku")) {
717+
sku = (String) subscriptionMap.get("sku");
718+
}
719+
720+
// Order ID.
721+
String orderId = null;
722+
if (subscriptionMap.containsKey("orderId")) {
723+
orderId = (String) subscriptionMap.get("orderId");
724+
}
725+
726+
// Signature.
727+
String signature = null;
728+
if (subscriptionMap.containsKey("signature")) {
729+
signature = (String) subscriptionMap.get("signature");
730+
}
731+
732+
// Purchase token.
733+
String purchaseToken = null;
734+
if (subscriptionMap.containsKey("purchaseToken")) {
735+
purchaseToken = (String) subscriptionMap.get("purchaseToken");
736+
}
737+
738+
// Create subscription object.
739+
AdjustPlayStoreSubscription subscription = new AdjustPlayStoreSubscription(
740+
price,
741+
currency,
742+
sku,
743+
orderId,
744+
signature,
745+
purchaseToken);
746+
747+
// Purchase time.
748+
if (subscriptionMap.containsKey("purchaseTime")) {
749+
try {
750+
long purchaseTime = Long.parseLong(subscriptionMap.get("purchaseTime").toString());
751+
subscription.setPurchaseTime(purchaseTime);
752+
} catch (NumberFormatException ignore) {}
753+
}
754+
755+
// Callback parameters.
756+
if (subscriptionMap.containsKey("callbackParameters")) {
757+
String strCallbackParametersJson = (String) subscriptionMap.get("callbackParameters");
758+
try {
759+
JSONObject jsonCallbackParameters = new JSONObject(strCallbackParametersJson);
760+
JSONArray callbackParametersKeys = jsonCallbackParameters.names();
761+
for (int i = 0; i < callbackParametersKeys.length(); ++i) {
762+
String key = callbackParametersKeys.getString(i);
763+
String value = jsonCallbackParameters.getString(key);
764+
subscription.addCallbackParameter(key, value);
765+
}
766+
} catch (JSONException e) {
767+
Log.e(TAG, "Failed to parse subscription callback parameter! Details: " + e);
768+
}
769+
}
770+
771+
// Partner parameters.
772+
if (subscriptionMap.containsKey("partnerParameters")) {
773+
String strPartnerParametersJson = (String) subscriptionMap.get("partnerParameters");
774+
try {
775+
JSONObject jsonPartnerParameters = new JSONObject(strPartnerParametersJson);
776+
JSONArray partnerParametersKeys = jsonPartnerParameters.names();
777+
for (int i = 0; i < partnerParametersKeys.length(); ++i) {
778+
String key = partnerParametersKeys.getString(i);
779+
String value = jsonPartnerParameters.getString(key);
780+
subscription.addPartnerParameter(key, value);
781+
}
782+
} catch (JSONException e) {
783+
Log.e(TAG, "Failed to parse subscription partner parameter! Details: " + e);
784+
}
785+
}
786+
787+
// Track subscription.
788+
Adjust.trackPlayStoreSubscription(subscription);
789+
result.success(null);
790+
}
791+
683792
private void setTestOptions(final MethodCall call, final Result result) {
684793
AdjustTestOptions testOptions = new AdjustTestOptions();
685794
Map testOptionsMap = (Map) call.arguments;
@@ -690,12 +799,18 @@ private void setTestOptions(final MethodCall call, final Result result) {
690799
if (testOptionsMap.containsKey("gdprUrl")) {
691800
testOptions.gdprUrl = (String) testOptionsMap.get("gdprUrl");
692801
}
802+
if (testOptionsMap.containsKey("subscriptionUrl")) {
803+
testOptions.subscriptionUrl = (String) testOptionsMap.get("subscriptionUrl");
804+
}
693805
if (testOptionsMap.containsKey("basePath")) {
694806
testOptions.basePath = (String) testOptionsMap.get("basePath");
695807
}
696808
if (testOptionsMap.containsKey("gdprPath")) {
697809
testOptions.gdprPath = (String) testOptionsMap.get("gdprPath");
698810
}
811+
if (testOptionsMap.containsKey("subscriptionPath")) {
812+
testOptions.subscriptionPath = (String) testOptionsMap.get("subscriptionPath");
813+
}
699814
if (testOptionsMap.containsKey("useTestConnectionOptions")) {
700815
testOptions.useTestConnectionOptions = testOptionsMap.get("useTestConnectionOptions").toString().equals("true");
701816
}

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.6.1'
8+
classpath('com.android.tools.build:gradle:4.0.0')
99
}
1010
}
1111

0 commit comments

Comments
 (0)