Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.0.50 #109

Merged
merged 10 commits into from
Oct 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Cordova AppsFlyer plugin version **4.4.0** and higher are meant to be used with

### <a id="plugin-build-for"> This plugin is built for

- iOS AppsFlyerSDK **v6.0.3**
- Android AppsFlyerSDK **v5.4.3**
- iOS AppsFlyerSDK **v6.0.5**
- Android AppsFlyerSDK **v5.4.4**

### <a id="breakingChanges"> ❗v6 Breaking Changes

Expand Down
11 changes: 11 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Release Notes
### 6.0.50
Release date **October 18 2020**
Release type: Major / Minor / **Hotfix**

**Overview and Highlights:**

- Install Referrer 2.1
- In App Purchase Validation
- Android SDk to 5.4.4
- iOS SDK to 6.0.5

### 6.0.30
Release date **September 6 2020**
Release type: Major / **Minor** / Hotfix
Expand Down
59 changes: 59 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ The list of available methods for this plugin is described below.
| [`getSdkVersion`](#getSdkVersion) | `((function success)` | Get the current SDK version |
| [`setSharingFilterForAllPartners`](#setSharingFilterForAllPartners) | | Used by advertisers to exclude all networks/integrated partners from getting data |
| [`setSharingFilter`](#setSharingFilter) | `(partners)` | Used by advertisers to exclude specified networks/integrated partners from getting data |
| [`validateAndLogInAppPurchase`](#validateAndLogInAppPurchase) | `(Object purchaseInfo, function success, function error)` | API for server verification of in-app purchases |
| [`setUseReceiptValidationSandbox`](#setUseReceiptValidationSandbox) | `(boolean isSandbox, function success, function error)` | In app purchase receipt validation Apple environment |

---

Expand Down Expand Up @@ -407,6 +409,63 @@ window.plugins.appsFlyer.setSharingFilter(partners);

---

##### <a id="validateAndLogInAppPurchase"> **`validateAndLogInAppPurchase(purchaseInfo, successC, failureC): void`**

Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported. [Learn more here](https://support.appsflyer.com/hc/en-us/articles/207032106-Receipt-validation-for-in-app-purchases)

*Example:*

```javascript
purchaseInfo = {
productIdentifier: 'identifier', //iOS
transactionId: '12xxx56', //iOS
publicKey: "key",
currency: 'biz',
signature: "sig",
purchaseData: "data",
price: '123',
additionalParameters: {'foo': 'bar'},
};
window.plugins.appsFlyer.setUseReceiptValidationSandbox(true); // iOS -> for testing in sandbox environment
window.plugins.appsFlyer.validateAndLogInAppPurchase(purchaseInfo, successC, failureC);
```

| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `purchaseInfo` | `Object` | In-App Purchase parameters |
| `successC` | `function` | success callback |
| `failureC` | `function` | failure callback |

*Purchase parameters:*

| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `publicKey` | `string` | License Key obtained from the Google Play Console |
| `signature` | `string` | data.INAPP_DATA_SIGNATURE |
| `purchaseData` | `string` | data.INAPP_PURCHASE_DATA |
| `price` | `string` | The product price |
| `additionalParameters` | `Object` | The additional param, which you want to receive it in the raw reports. |
| `productIdentifier` | `string` | The product identifier. *FOR iOS* |
| `transactionId` | `string` | The purchase transaction Id. *FOR iOS* |
| `currency` | `string` | The product currency |
---

##### <a id="setUseReceiptValidationSandbox"> **`setUseReceiptValidationSandbox(isSandbox, successC, failureC): void`**

In app purchase receipt validation Apple environment(production or sandbox)<br>Callback functions are optional.

*Example:*

```javascript
window.plugins.appsFlyer.setUseReceiptValidationSandbox(true);
```

| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `isSandbox` | `boolean` | true if In app purchase is done with sandbox |

---

### <a id="deep-linking-tracking"> Deep linking Tracking


Expand Down
11 changes: 11 additions & 0 deletions docs/RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Release Notes
### 6.0.50
Release date **October 18 2020**
Release type: Major / Minor / **Hotfix**

**Overview and Highlights:**

- Install Referrer 2.1
- In App Purchase Validation
- Android SDk to 5.4.4
- iOS SDK to 6.0.5

### 6.0.30
Release date **September 6 2020**
Release type: Major / **Minor** / Hotfix
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-appsflyer-sdk",
"version": "6.0.30",
"version": "6.0.50",
"description": "Cordova AppsFlyer SDK Plugin",
"cordova": {
"id": "cordova-plugin-appsflyer-sdk",
Expand Down
8 changes: 4 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-appsflyer-sdk"
version="6.0.30">
version="6.0.50">
<name>AppsFlyer</name>
<description>Cordova Plugin AppsFlyer</description>
<license>Apache 2.0</license>
Expand All @@ -40,7 +40,7 @@
</js-module>




<!-- android -->
<platform name="android">
Expand All @@ -63,13 +63,13 @@

<source-file src="src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java" target-dir="src/com/appsflyer/cordova/plugin" />
<source-file src="src/android/com/appsflyer/cordova/plugin/AppsFlyerConstants.java" target-dir="src/com/appsflyer/cordova/plugin" />

<framework src="src/android/cordovaAF.gradle" custom="true" type="gradleReference" />
</platform>


<!-- ios -->
<platform name="ios">
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="AppsFlyerPlugin">
<param name="ios-package" value="AppsFlyerPlugin" />
Expand Down
11 changes: 11 additions & 0 deletions src/android/com/appsflyer/cordova/plugin/AppsFlyerConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ public class AppsFlyerConstants {
final static String INVITE_CUSTOMERID = "customerID";
final static String INVITE_DEEPLINK = "baseDeepLink";
final static String PROMOTE_ID = "promotedAppId";

//RECEIPT VALIDATION
final static String PUBLIC_KEY = "publicKey";
final static String SIGNATURE = "signature";
final static String PURCHASE_DATA = "purchaseData";
final static String PRICE = "price";
final static String CURRENCY = "currency";
final static String ADDITIONAL_PARAMETERS = "additionalParameters";
final static String NO_PARAMETERS_ERROR = "Please provide purchase parameters";
final static String VALIDATE_SUCCESS = "In-App Purchase Validation success";
final static String VALIDATE_FAILED = "In-App Purchase Validation failed with error: ";
}
118 changes: 94 additions & 24 deletions src/android/com/appsflyer/cordova/plugin/AppsFlyerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void onNewIntent(Intent intent) {
}

/**
*
* @param action The action name to call into.
* @param args Arguments to pass into the native environment.
* @param callbackContext Success and Error function callback (optionally with an error/success parameter)
Expand Down Expand Up @@ -97,10 +96,12 @@ public boolean execute(final String action, JSONArray args, CallbackContext call
return onResume(args, callbackContext);
} else if ("getSdkVersion".equals(action)) {
return getSdkVersion(callbackContext);
}else if ("setSharingFilter".equals(action)) {
} else if ("setSharingFilter".equals(action)) {
return setSharingFilter(args, callbackContext);
}else if ("setSharingFilterForAllPartners".equals(action)) {
} else if ("setSharingFilterForAllPartners".equals(action)) {
return setSharingFilterForAllPartners(callbackContext);
} else if ("validateAndLogInAppPurchase".equals(action)) {
return validateAndLogInAppPurchase(args, callbackContext);
}

return false;
Expand All @@ -116,10 +117,9 @@ private void trackAppLaunch() {
}

/**
* Get the deeplink data
* @param callbackContext
* Success callback - called after receiving data on App Open Attribution.
* Error callback - called when error occurs.
* Get the deeplink data
* @param callbackContext Success callback - called after receiving data on App Open Attribution.
* Error callback - called when error occurs.
* @return
*/
private boolean registerOnAppOpenAttribution(final CallbackContext callbackContext) {
Expand All @@ -131,14 +131,13 @@ private boolean registerOnAppOpenAttribution(final CallbackContext callbackConte
return true;
}

/** initialize the SDK.
/**
* initialize the SDK.
* @param args SDK configuration
* @param callbackContext Success callback - called after successful SDK initialization.
* errorCB: Error callback - called when error occurs during initialization.
*/
private boolean initSdk(final JSONArray args, final CallbackContext callbackContext) {


String devKey = null;
boolean isConversionData;
boolean isDebug = false;
Expand Down Expand Up @@ -328,10 +327,11 @@ private void sendEvent(JSONObject params) {
}
};
}

/**
* Track rich in-app events
* @param parameters eventName: custom event name, is presented in your dashboard.
* eventValue: event details
* @param parameters eventName: custom event name, is presented in your dashboard.
* eventValue: event details
* @param callbackContext Success callback - called after successful event tracking.
* Error callback - called when error occurs.
* @return
Expand Down Expand Up @@ -387,7 +387,7 @@ private boolean setCurrencyCode(JSONArray parameters) {

/**
* Setting your own Custom ID enables you to cross-reference your own unique ID with AppsFlyer’s user ID and the other devices’ IDs.
* @param parameters customerUserId
* @param parameters customerUserId
* @param callbackContext Success and Error callbacks.
* @return
*/
Expand Down Expand Up @@ -488,7 +488,7 @@ private static Map<String, Object> jsonToMap(String inputString) {

/**
* (Android) Allows to pass GCM/FCM Tokens that where collected by third party plugins to the AppsFlyer server. Can be used for Uninstall Tracking.
* @param parameters token
* @param parameters token
* @param callbackContext null in this case. We dont use callbacks for this method
* @return
*/
Expand Down Expand Up @@ -530,9 +530,10 @@ private boolean onResume(JSONArray parameters, CallbackContext callbackContext)
}

// USER INVITE

/**
* Set AppsFlyer’s OneLink ID
* @param parameters oneLinkID.
* @param parameters oneLinkID.
* @param callbackContext null in this case. We dont use callbacks for this method
* @return
*/
Expand All @@ -555,7 +556,7 @@ private boolean setAppInviteOneLinkID(JSONArray parameters, CallbackContext call

/**
* Allowing your existing users to invite their friends and contacts as new users to your app
* @param args Parameters for Invite link
* @param args Parameters for Invite link
* @param callbackContext Success callback (generated link) and Error callback.
* @return
*/
Expand Down Expand Up @@ -640,8 +641,8 @@ public void onResponseError(String s) {

/**
* Track cross promotion impression. Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard.
* @param parameters appId: Promoted Application ID
* campaign: Promoted Campaign
* @param parameters appId: Promoted Application ID
* campaign: Promoted Campaign
* @param callbackContext
* @return
*/
Expand Down Expand Up @@ -672,9 +673,9 @@ public boolean trackCrossPromotionImpression(JSONArray parameters, CallbackConte

/**
* Use this call to track the click and launch the app store's app page (via Browser)
* @param parameters promotedAppId: Promoted Application ID
* campaign: Promoted Campaign
* userParams: Additional Parameters to track
* @param parameters promotedAppId: Promoted Application ID
* campaign: Promoted Campaign
* userParams: Additional Parameters to track
* @param callbackContext
* @return
*/
Expand Down Expand Up @@ -711,7 +712,7 @@ public boolean trackAndOpenStore(JSONArray parameters, CallbackContext callbackC

/**
* Helper function to send a callback with no results.
* @param callbackContext
* @param callbackContext
*/
private void sendPluginNoResult(CallbackContext callbackContext) {
PluginResult pluginResult = new PluginResult(
Expand All @@ -732,8 +733,8 @@ private boolean getSdkVersion(CallbackContext callbackContext) {
return true;
}

/**
* @param parameters Comma separated array of partners that need to be excluded
/**
* @param parameters Comma separated array of partners that need to be excluded
* @param callbackContext
*/
private boolean setSharingFilter(JSONArray parameters, CallbackContext callbackContext) {
Expand Down Expand Up @@ -769,4 +770,73 @@ private boolean setSharingFilterForAllPartners(CallbackContext callbackContext)
callbackContext.success(SUCCESS);
return true;
}

/**
* Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported.
* Learn more - https://support.appsflyer.com/hc/en-us/articles/207032106-Receipt-validation-for-in-app-purchases
* @param purchase info, success and failure callbacks
*/
public boolean validateAndLogInAppPurchase(JSONArray args, CallbackContext callbackContext) {
String publicKey = "";
String signature = "";
String purchaseData = "";
String price = "";
String currency = "";
Map<String, String> additionalParameters = null;
JSONObject additionalParametersJson;

try {
final JSONObject purchaseInfo = args.getJSONObject(0);

publicKey = purchaseInfo.optString(PUBLIC_KEY, "");
signature = purchaseInfo.optString(SIGNATURE, "");
purchaseData = purchaseInfo.optString(PURCHASE_DATA, "");
price = purchaseInfo.optString(PRICE, "");
currency = purchaseInfo.optString(CURRENCY, "");
if (purchaseInfo.has(ADDITIONAL_PARAMETERS)) {
additionalParametersJson = purchaseInfo.optJSONObject(ADDITIONAL_PARAMETERS);
additionalParameters = toMap(additionalParametersJson);
}

if (publicKey == "" || signature == "" || purchaseData == "" || price == "" || currency == "") {
callbackContext.error(NO_PARAMETERS_ERROR);
return true;
}
} catch (JSONException e) {
e.printStackTrace();
callbackContext.error(FAILURE);
return true;
}
initInAppPurchaseValidatorListener(callbackContext);
AppsFlyerLib.getInstance().validateAndTrackInAppPurchase(this.cordova.getContext(), publicKey, signature, purchaseData, price, currency, additionalParameters);
return true;
}


public void initInAppPurchaseValidatorListener(final CallbackContext callbackContext) {
AppsFlyerLib.getInstance().registerValidatorListener(this.cordova.getContext(), new AppsFlyerInAppPurchaseValidatorListener() {
@Override
public void onValidateInApp() {
callbackContext.success(VALIDATE_SUCCESS);

}

@Override
public void onValidateInAppFailure(String error) {
callbackContext.error(VALIDATE_FAILED + error);

}
});
}

private Map<String, String> toMap(JSONObject jsonobj) throws JSONException {
Map<String, String> map = new HashMap<String, String>();
Iterator<String> keys = jsonobj.keys();
while (keys.hasNext()) {
String key = keys.next();
String value = (String) jsonobj.get(key);
map.put(key, value);
}
return map;
}
}
Loading