Skip to content

Commit

Permalink
Merge pull request #17 from adjust/v4220
Browse files Browse the repository at this point in the history
Version 4.22.0
  • Loading branch information
uerceg authored Jun 9, 2020
2 parents 59a2f2a + d1188a4 commit 3acdf18
Show file tree
Hide file tree
Showing 26 changed files with 635 additions and 68 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### Version 4.22.0 (10th June 2020)
#### Added
- Added subscription tracking feature.
- Added support for Huawei App Gallery install referrer.

#### Changed
- Updated communication flow with `iAd.framework`.

#### Native SDKs
- [[email protected]][ios_sdk_v4.22.1]
- [[email protected]][android_sdk_v4.22.0]

---

### Version 4.21.0 (25th March 2021)
#### Added
- Added `disableThirdPartySharing` method to `Adjust` interface to allow disabling of data sharing with third parties outside of Adjust ecosystem.
Expand Down Expand Up @@ -98,7 +112,9 @@
[ios_sdk_v4.18.0]: https://github.com/adjust/ios_sdk/tree/v4.18.0
[ios_sdk_v4.18.3]: https://github.com/adjust/ios_sdk/tree/v4.18.3
[ios_sdk_v4.21.0]: https://github.com/adjust/ios_sdk/tree/v4.21.0
[ios_sdk_v4.22.1]: https://github.com/adjust/ios_sdk/tree/v4.22.1

[android_sdk_v4.17.0]: https://github.com/adjust/android_sdk/tree/v4.17.0
[android_sdk_v4.18.0]: https://github.com/adjust/android_sdk/tree/v4.18.0
[android_sdk_v4.21.0]: https://github.com/adjust/android_sdk/tree/v4.21.0
[android_sdk_v4.22.0]: https://github.com/adjust/android_sdk/tree/v4.22.0
106 changes: 105 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ This is the Flutter SDK of Adjust™. You can read more about Adjust™ at [adju

### Additional features

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

```yaml
dependencies:
adjust_sdk: ^4.21.0
adjust_sdk: ^4.22.0
```
Then navigate to your project in the terminal and run:
Expand Down Expand Up @@ -595,6 +596,109 @@ In this case, this will make the Adjust SDK not send the initial install session

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

### <a id="af-subscription-tracking"></a>Subscription tracking

**Note**: This feature is only available in the SDK v4.22.0 and above.

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:

**For App Store subscription:**

```dart
AdjustAppStoreSubscription subscription = new AdjustAppStoreSubscription(
price,
currency,
transactionId,
receipt);
subscription.setTransactionDate(transactionDate);
subscription.setSalesRegion(salesRegion);
Adjust.trackAppStoreSubscription(subscription);
```

**For Play Store subscription:**

```dart
AdjustPlayStoreSubscription subscription = new AdjustPlayStoreSubscription(
price,
currency,
sku,
orderId,
signature,
purchaseToken);
subscription.setPurchaseTime(purchaseTime);
Adjust.trackPlayStoreSubscription(subscription);
```

Subscription tracking parameters for App Store subscription:

- [price](https://developer.apple.com/documentation/storekit/skproduct/1506094-price?language=objc)
- 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)
- [transactionId](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411288-transactionidentifier?language=objc)
- [receipt](https://developer.apple.com/documentation/foundation/nsbundle/1407276-appstorereceipturl)
- [transactionDate](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411273-transactiondate?language=objc)
- 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)

Subscription tracking parameters for Play Store subscription:

- [price](https://developer.android.com/reference/com/android/billingclient/api/SkuDetails#getpriceamountmicros)
- [currency](https://developer.android.com/reference/com/android/billingclient/api/SkuDetails#getpricecurrencycode)
- [sku](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getsku)
- [orderId](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getorderid)
- [signature](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getsignature)
- [purchaseToken](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getpurchasetoken)
- [purchaseTime](https://developer.android.com/reference/com/android/billingclient/api/Purchase#getpurchasetime)

**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.

Just like with event tracking, you can attach callback and partner parameters to the subscription object as well:

**For App Store subscription:**

```dart
AdjustAppStoreSubscription subscription = new AdjustAppStoreSubscription(
price,
currency,
transactionId,
receipt);
subscription.setTransactionDate(transactionDate);
subscription.setSalesRegion(salesRegion);
// add callback parameters
subscription.addCallbackParameter('key', 'value');
subscription.addCallbackParameter('foo', 'bar');
// add partner parameters
subscription.addPartnerParameter('key', 'value');
subscription.addPartnerParameter('foo', 'bar');
Adjust.trackAppStoreSubscription(subscription);
```

**For Play Store subscription:**

```dart
AdjustPlayStoreSubscription subscription = new AdjustPlayStoreSubscription(
price,
currency,
sku,
orderId,
signature,
purchaseToken);
subscription.setPurchaseTime(purchaseTime);
// add callback parameters
subscription.addCallbackParameter('key', 'value');
subscription.addCallbackParameter('foo', 'bar');
// add partner parameters
subscription.addPartnerParameter('key', 'value');
subscription.addPartnerParameter('foo', 'bar');
Adjust.trackPlayStoreSubscription(subscription);
```

### <a id="af-push-token"></a>Push token (uninstall tracking)

Push tokens are used for Audience Builder and client callbacks, and they are required for uninstall and reinstall tracking.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.21.0
4.22.0
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath('com.android.tools.build:gradle:4.0.0')
}
}
rootProject.allprojects {
Expand Down Expand Up @@ -36,5 +36,5 @@ android {
}

dependencies {
implementation 'com.adjust.sdk:adjust-android:4.21.0'
implementation 'com.adjust.sdk:adjust-android:4.22.0'
}
115 changes: 115 additions & 0 deletions android/src/main/java/com/adjust/sdk/flutter/AdjustSdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.adjust.sdk.AdjustEventSuccess;
import com.adjust.sdk.AdjustSessionFailure;
import com.adjust.sdk.AdjustSessionSuccess;
import com.adjust.sdk.AdjustPlayStoreSubscription;
import com.adjust.sdk.AdjustTestOptions;
import com.adjust.sdk.LogLevel;
import com.adjust.sdk.OnAttributionChangedListener;
Expand Down Expand Up @@ -143,6 +144,12 @@ public void onMethodCall(MethodCall call, final Result result) {
case "trackAdRevenue":
trackAdRevenue(call, result);
break;
case "trackAppStoreSubscription":
trackAppStoreSubscription(result);
break;
case "trackPlayStoreSubscription":
trackPlayStoreSubscription(call, result);
break;
case "setTestOptions":
setTestOptions(call, result);
break;
Expand Down Expand Up @@ -680,6 +687,108 @@ private void trackAdRevenue(final MethodCall call, final Result result) {
result.success(null);
}

private void trackAppStoreSubscription(final Result result) {
result.error("0", "Error. No App Store subscription tracking for Android plaftorm!", null);
}

private void trackPlayStoreSubscription(final MethodCall call, final Result result) {
Map subscriptionMap = (Map) call.arguments;
if (subscriptionMap == null) {
return;
}

// Price.
long price = -1;
if (subscriptionMap.containsKey("price")) {
try {
price = Long.parseLong(subscriptionMap.get("price").toString());
} catch (NumberFormatException ignore) {}
}

// Currency.
String currency = null;
if (subscriptionMap.containsKey("currency")) {
currency = (String) subscriptionMap.get("currency");
}

// SKU.
String sku = null;
if (subscriptionMap.containsKey("sku")) {
sku = (String) subscriptionMap.get("sku");
}

// Order ID.
String orderId = null;
if (subscriptionMap.containsKey("orderId")) {
orderId = (String) subscriptionMap.get("orderId");
}

// Signature.
String signature = null;
if (subscriptionMap.containsKey("signature")) {
signature = (String) subscriptionMap.get("signature");
}

// Purchase token.
String purchaseToken = null;
if (subscriptionMap.containsKey("purchaseToken")) {
purchaseToken = (String) subscriptionMap.get("purchaseToken");
}

// Create subscription object.
AdjustPlayStoreSubscription subscription = new AdjustPlayStoreSubscription(
price,
currency,
sku,
orderId,
signature,
purchaseToken);

// Purchase time.
if (subscriptionMap.containsKey("purchaseTime")) {
try {
long purchaseTime = Long.parseLong(subscriptionMap.get("purchaseTime").toString());
subscription.setPurchaseTime(purchaseTime);
} catch (NumberFormatException ignore) {}
}

// Callback parameters.
if (subscriptionMap.containsKey("callbackParameters")) {
String strCallbackParametersJson = (String) subscriptionMap.get("callbackParameters");
try {
JSONObject jsonCallbackParameters = new JSONObject(strCallbackParametersJson);
JSONArray callbackParametersKeys = jsonCallbackParameters.names();
for (int i = 0; i < callbackParametersKeys.length(); ++i) {
String key = callbackParametersKeys.getString(i);
String value = jsonCallbackParameters.getString(key);
subscription.addCallbackParameter(key, value);
}
} catch (JSONException e) {
Log.e(TAG, "Failed to parse subscription callback parameter! Details: " + e);
}
}

// Partner parameters.
if (subscriptionMap.containsKey("partnerParameters")) {
String strPartnerParametersJson = (String) subscriptionMap.get("partnerParameters");
try {
JSONObject jsonPartnerParameters = new JSONObject(strPartnerParametersJson);
JSONArray partnerParametersKeys = jsonPartnerParameters.names();
for (int i = 0; i < partnerParametersKeys.length(); ++i) {
String key = partnerParametersKeys.getString(i);
String value = jsonPartnerParameters.getString(key);
subscription.addPartnerParameter(key, value);
}
} catch (JSONException e) {
Log.e(TAG, "Failed to parse subscription partner parameter! Details: " + e);
}
}

// Track subscription.
Adjust.trackPlayStoreSubscription(subscription);
result.success(null);
}

private void setTestOptions(final MethodCall call, final Result result) {
AdjustTestOptions testOptions = new AdjustTestOptions();
Map testOptionsMap = (Map) call.arguments;
Expand All @@ -690,12 +799,18 @@ private void setTestOptions(final MethodCall call, final Result result) {
if (testOptionsMap.containsKey("gdprUrl")) {
testOptions.gdprUrl = (String) testOptionsMap.get("gdprUrl");
}
if (testOptionsMap.containsKey("subscriptionUrl")) {
testOptions.subscriptionUrl = (String) testOptionsMap.get("subscriptionUrl");
}
if (testOptionsMap.containsKey("basePath")) {
testOptions.basePath = (String) testOptionsMap.get("basePath");
}
if (testOptionsMap.containsKey("gdprPath")) {
testOptions.gdprPath = (String) testOptionsMap.get("gdprPath");
}
if (testOptionsMap.containsKey("subscriptionPath")) {
testOptions.subscriptionPath = (String) testOptionsMap.get("subscriptionPath");
}
if (testOptionsMap.containsKey("useTestConnectionOptions")) {
testOptions.useTestConnectionOptions = testOptionsMap.get("useTestConnectionOptions").toString().equals("true");
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath('com.android.tools.build:gradle:4.0.0')
}
}

Expand Down
Loading

0 comments on commit 3acdf18

Please sign in to comment.