diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml
new file mode 100644
index 00000000..39c0d1e5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -0,0 +1,74 @@
+---
+assignees: []
+body:
+ -
+ attributes:
+ description: "What is the problem? A clear and concise description of what the bug is."
+ label: "Describe the bug"
+ placeholder: "Tell us what you see!"
+ id: description
+ type: textarea
+ validations:
+ required: true
+ -
+ attributes:
+ description: "Please provide as much step-by-step detail as possible including logs, stack traces, and uncaught exceptions."
+ label: "Steps to reproduce"
+ value: |
+ 1.
+ 2.
+ 3.
+ id: steps
+ type: textarea
+ validations:
+ required: true
+ -
+ attributes:
+ description: "What did you expect to happen?"
+ label: "Expected behavior"
+ id: expected
+ type: textarea
+ validations:
+ required: true
+ -
+ attributes:
+ description: "What version of sdk are you seeing this issue on?"
+ label: "SDK Version"
+ placeholder: "5.2.0"
+ id: sdk-version
+ type: input
+ validations:
+ required: true
+ -
+ attributes:
+ description: "What devices or emulators are you seeing this bug on?"
+ label: Make and Model
+ placeholder: "iPhone 13 / Samsung S21"
+ id: device
+ type: input
+ validations:
+ required: true
+ -
+ attributes:
+ description: "What version of the device OS?"
+ label: OS
+ placeholder: "iOS 15.6.1 / Android 12"
+ id: os
+ type: input
+ validations:
+ required: true
+ -
+ attributes:
+ description: "Anything else that might be relevant for troubleshooting this bug. Any screenshots or videos that show the issue are very helpful."
+ label: "Additional Information/Context"
+ id: context
+ type: textarea
+ validations:
+ required: false
+
+description: "Found a bug in the Branch Cordova SDK? File it here."
+labels:
+ - bug
+ - needs-triage
+name: "🐞 Bug report"
+title: "(short issue description)"
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 00000000..aa56f767
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,9 @@
+---
+blank_issues_enabled: false
+contact_links:
+ - name: "📕 Documentation Issue"
+ url: https://help.branch.io/developers-hub/docs/cordova-phonegap-ionic
+ about: Report an issue in the Branch Cordova SDK Reference documentation by clicking "Suggest edits" button on the documentation page.
+ - name: "Branch Support"
+ url: https://help.branch.io/using-branch/page/submit-a-ticket
+ about: If you are having general trouble with Branch Cordova SDK integration, please submit a ticket to Branch Support.
diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml
new file mode 100644
index 00000000..c8832d1b
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature-request.yml
@@ -0,0 +1,14 @@
+---
+name: 🚀 Feature Request
+description: Suggest an idea for this project
+title: "(short issue description)"
+labels: [feature-request, needs-triage]
+assignees: []
+body:
+ - type: textarea
+ id: description
+ attributes:
+ label: Describe the feature
+ description: A clear and concise description of the feature you are proposing.
+ validations:
+ required: true
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 00000000..d43e2e43
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,29 @@
+## Reference
+SDK-XXXX --
.
+
+## Summary
+
+
+## Motivation
+
+
+## Type Of Change
+
+- [ ] Bug fix (non-breaking change which fixes an issue)
+- [ ] New feature (non-breaking change which adds functionality)
+- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
+- [ ] This change requires a documentation update
+
+## Testing Instructions
+
+
+
+
+
+
+
+
+
+
+
+cc @BranchMetrics/saas-sdk-devs for visibility.
diff --git a/.github/workflows/README.md b/.github/workflows/README.md
new file mode 100644
index 00000000..e69de29b
diff --git a/.github/workflows/automation-trigger-test.yml b/.github/workflows/automation-trigger-test.yml
new file mode 100644
index 00000000..146899ab
--- /dev/null
+++ b/.github/workflows/automation-trigger-test.yml
@@ -0,0 +1,18 @@
+#on: [push]
+on:
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/github-script@v6
+ with:
+ github-token: ${{ secrets.BRANCHLET_ACCESS_TOKEN_PUBLIC }}
+ script: |
+ await github.rest.actions.createWorkflowDispatch({
+ owner: 'BranchMetrics',
+ repo: 'qentelli-saas-sdk-cordova-testing-automation',
+ workflow_id: 'cordova-manual.yml',
+ ref: 'master'
+ })
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 00000000..4ae1061a
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,28 @@
+# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
+#
+# You can adjust the behavior by modifying this file.
+# For more information, see:
+# https://github.com/actions/stale
+name: Mark stale issues
+
+on:
+ schedule:
+ - cron: '0 0 * * *'
+
+jobs:
+ stale:
+
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+
+ steps:
+ - uses: actions/stale@v5
+ with:
+ repo-token: ${{ secrets.STALE_PERSONAL_ACCESS_TOKEN }}
+ days-before-issue-stale: 60
+ days-before-close: 7
+ stale-issue-message: 'This issue has been automatically marked as stale due to inactivity for 60 days. If this issue is still relevant, please respond with any updates or this issue will be closed in 7 days. If you believe this is a mistake, please comment to let us know. Thank you for your contributions.'
+ stale-issue-label: 'no-issue-activity'
+ close-issue-message: 'This issue has been closed due to inactivity. If this issue is still relevant, please reopen it or create a new one. Thank you for your contributions.'
+ start-date: '2023-05-22'
diff --git a/.gitignore b/.gitignore
index f3485004..156a3967 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@ npm-debug.log*
yarn-error.log*
.vscode
.idea
+cordova-ionic-phonegap-branch-deep-linking-attribution.iml
src/android/.idea
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55df6eac..08b94cbe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,47 @@
+5.2.1 Jan 4, 2023
+* Fix Javascript method setLogging to enable logging in the native layer.
+* Update Android SDK to 5.2.7
+* Update iOS SDK to 1.45.2
+
+5.2.0 August 8th, 2022
+* Update iOS SDK to 1.43.1
+* Update Android SDK to 5.2.0
+* Added method to generate Branch QR codes, getBranchQRCode().
+
+5.1.0 May 27, 2022
+* Update iOS SDK to 1.42.0
+* Update Android SDK to 5.1.5
+* Update 3rd party dependencies. Of note the plist vulnerability. (Thanks Sujay-shetty)
+* Replace setDebug with setLogging and test devices. https://help.branch.io/using-branch/docs/adding-test-devices
+
+5.0.2 February 9, 2022
+* Update dependencies to latest non-breaking versions, of note the shelljs vulnerability. (Thanks again Sujay-shetty!)
+
+5.0.1 February 8, 2022
+* Remove request package (thanks for catching Sujay-shetty)
+
+5.0.0 January 21, 2022
+* Add content items support in sendBranchEvent
+* Remove sendCommerceEvent
+* Fix bug where custom data would clobber other fields when creating event in Android plugin
+* Update iOS SDK to 1.40.2
+* Update Android SDK to 5.0.15
+
+4.2.4 - May 3, 2021
+
+CORE-1898 correct iOS API signature for LATD
+Fix alternate link domain issue - Thanks MaximBelov
+Fix exist check - Thanks MaximBelov
+
+4.2.3 - April 29, 2021
+
+Update Android SDK to 5.0.8
+
+4.2.2 - April 28, 2021
+
+Update iOS SDK to 1.39.2
+Update Android SDK to 5.0.7
+
# [4.2.1](https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/compare/v4.2.0...v4.2.1) (2020-11-05)
# [4.2.0](https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/compare/v4.1.3...v4.2.0) (2020-8-26)
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 00000000..3ef2448a
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,5 @@
+# Security Policy
+
+## Reporting a Vulnerability
+If you discover a potential security issue in this project we ask that you notify Branch Security directly via email to security@branch.io
+Please do not open GitHub issues or pull requests - this makes the problem immediately visible to everyone, including malicious actors.
diff --git a/package.json b/package.json
index 7e8a2790..76e277b1 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "branch-cordova-sdk",
"description": "Branch Metrics Cordova SDK",
"main": "src/index.js",
- "version": "4.2.2",
+ "version": "5.2.1",
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
"repository": {
"type": "git",
@@ -55,24 +55,23 @@
]
},
"dependencies": {
- "fs": "0.0.1-security",
- "glob": "^7.1.4",
+ "glob": "^8.0.3",
"mkpath": "^1.0.0",
- "node-version-compare": "^1.0.1",
- "plist": "^3.0.1",
- "request": "^2.85.0",
- "shelljs": "^0.8.3",
- "xcode": "^2.0.0",
- "xml2js": "^0.4.19"
+ "node-version-compare": "^1.0.3",
+ "plist": "^3.0.5",
+ "shelljs": "^0.8.5",
+ "xcode": "^3.0.1",
+ "xml2js": "^0.4.23"
},
"devDependencies": {
- "@commitlint/cli": "^8.3.5",
- "@commitlint/config-conventional": "^8.3.4",
- "eslint": "^6.8.0",
- "eslint-config-airbnb-base": "^14.1.0",
- "eslint-plugin-import": "^2.20.2",
- "husky": "^4.2.5",
- "lint-staged": "^10.1.7",
- "prettier": "^2.0.5"
+ "fs": "0.0.1-security",
+ "@commitlint/cli": "^17.0.1",
+ "@commitlint/config-conventional": "^17.0.0",
+ "eslint": "^8.16.0",
+ "eslint-config-airbnb-base": "^15.0.0",
+ "eslint-plugin-import": "^2.26.0",
+ "husky": "^8.0.1",
+ "lint-staged": "^12.4.2",
+ "prettier": "^2.6.2"
}
}
diff --git a/plugin.xml b/plugin.xml
index 87a6f95b..0ac900f8 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -24,7 +24,7 @@ SOFTWARE.
+ version="5.2.1">
branch-cordova-sdk
@@ -63,7 +63,7 @@ SOFTWARE.
-
+
@@ -84,10 +84,10 @@ SOFTWARE.
-
+
-
+
diff --git a/src/__tests__/index.js b/src/__tests__/index.js
index 8a843114..bd340080 100644
--- a/src/__tests__/index.js
+++ b/src/__tests__/index.js
@@ -66,18 +66,7 @@ exports.defineAutoTests = function() {
expect(window.Branch.userCompletedAction).toBeDefined();
expect(_typeof(window.Branch.userCompletedAction)).toBe("function");
});
- it("should contain a method called loadRewards()", function() {
- expect(window.Branch.loadRewards).toBeDefined();
- expect(_typeof(window.Branch.loadRewards)).toBe("function");
- });
- it("should contain a method called redeemRewards()", function() {
- expect(window.Branch.redeemRewards).toBeDefined();
- expect(_typeof(window.Branch.redeemRewards)).toBe("function");
- });
- it("should contain a method called creditHistory()", function() {
- expect(window.Branch.creditHistory).toBeDefined();
- expect(_typeof(window.Branch.creditHistory)).toBe("function");
- });
+
});
describe("Branch.getLatestReferringParams()", function() {
@@ -219,80 +208,4 @@ exports.defineAutoTests = function() {
10000
);
});
-
- describe("Branch.loadRewards()", function() {
- beforeEach(function(done) {
- initSession().then(function() {
- done();
- });
- }, 3000);
- it(
- "should return an object response",
- function(done) {
- window.Branch.loadRewards().then(
- function(res) {
- expect(
- typeof res === "undefined" ? "undefined" : _typeof(res)
- ).toBe("number");
- done();
- },
- function(err) {
- expect(
- typeof err === "undefined" ? "undefined" : _typeof(err)
- ).toBe("string");
- done();
- }
- );
- },
- 10000
- );
- });
-
- describe("Branch.redeemRewards()", function() {
- beforeEach(function(done) {
- initSession().then(function() {
- done();
- });
- }, 3000);
- it(
- "should return an object/string error response",
- function(done) {
- window.Branch.redeemRewards(100).then(
- function(res) {
- expect(
- typeof res === "undefined" ? "undefined" : _typeof(res)
- ).toBe("object");
- done();
- },
- function(err) {
- expect(
- typeof err === "undefined" ? "undefined" : _typeof(err)
- ).toBe("string");
- done();
- }
- );
- },
- 10000
- );
- });
-
- describe("Branch.creditHistory()", function() {
- beforeEach(function(done) {
- initSession().then(function() {
- done();
- });
- }, 3000);
- it(
- "should return the credit balance",
- function(done) {
- window.Branch.creditHistory().then(function(res) {
- expect(typeof res === "undefined" ? "undefined" : _typeof(res)).toBe(
- "object"
- );
- done();
- });
- },
- 10000
- );
- });
};
diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java
index cc23d603..ea7b11a5 100644
--- a/src/android/io/branch/BranchSDK.java
+++ b/src/android/io/branch/BranchSDK.java
@@ -1,40 +1,39 @@
package io.branch;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
-import android.util.Log;
-import android.annotation.TargetApi;
import android.net.Uri;
import android.os.Build;
+import android.util.Log;
+import android.util.Base64;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.PluginResult;
-
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Iterator;
+import java.io.IOException;
import io.branch.indexing.BranchUniversalObject;
import io.branch.referral.Branch;
-import io.branch.referral.PrefHelper;
import io.branch.referral.BranchError;
import io.branch.referral.BranchViewHandler;
+import io.branch.referral.ServerRequestGetCPID.BranchCrossPlatformIdListener;
+import io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener;
import io.branch.referral.SharingHelper;
+import io.branch.referral.QRCode.BranchQRCode;
import io.branch.referral.util.BRANCH_STANDARD_EVENT;
+import io.branch.referral.util.BranchCPID;
import io.branch.referral.util.BranchEvent;
-import io.branch.referral.util.CommerceEvent;
+import io.branch.referral.util.ContentMetadata;
import io.branch.referral.util.CurrencyType;
-import io.branch.referral.util.Product;
-import io.branch.referral.util.ProductCategory;
import io.branch.referral.util.ShareSheetStyle;
-import io.branch.referral.ServerRequestGetLATD.BranchLastAttributedTouchDataListener;
-import io.branch.referral.ServerRequestGetCPID.BranchCrossPlatformIdListener;
-import io.branch.referral.util.BranchCPID;
public class BranchSDK extends CordovaPlugin {
@@ -124,7 +123,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
Runnable r = new RunnableThread(action, args, callbackContext);
- if (action.equals("setDebug")) {
+ if (action.equals("enableLogging")) {
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("setCookieBasedMatching")) {
@@ -146,21 +145,14 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
return true;
} else if (action.equals("userCompletedAction")) {
if (args.length() < 1 && args.length() > 2) {
- callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
- return false;
- }
- cordova.getActivity().runOnUiThread(r);
- return true;
- } else if (action.equals("sendCommerceEvent")) {
- if (args.length() < 1 && args.length() > 2) {
- callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
+ callbackContext.error(String.format("Parameter count mismatch"));
return false;
}
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("sendBranchEvent")) {
if (args.length() < 1 && args.length() > 2) {
- callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
+ callbackContext.error(String.format("Parameter count mismatch"));
return false;
}
cordova.getActivity().runOnUiThread(r);
@@ -174,22 +166,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
} else if (action.equals("logout")) {
cordova.getActivity().runOnUiThread(r);
return true;
- } else if (action.equals("loadRewards")) {
- cordova.getActivity().runOnUiThread(r);
- return true;
- } else if (action.equals("redeemRewards")) {
- if (args.length() < 1 && args.length() > 2) {
- callbackContext.error(String.format("Parameter mismatched. 1-2 is required but %d is given", args.length()));
- return false;
- }
- cordova.getActivity().runOnUiThread(r);
- return true;
- } else if (action.equals("getCreditHistory")) {
- cordova.getActivity().runOnUiThread(r);
- return true;
} else if (action.equals("createBranchUniversalObject")) {
if (args.length() != 1) {
- callbackContext.error(String.format("Parameter mismatched. 1 is required but %d is given", args.length()));
+ callbackContext.error(String.format("Parameter count mismatch"));
return false;
}
cordova.getActivity().runOnUiThread(r);
@@ -201,25 +180,25 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
} else if (action.equals("lastAttributedTouchData")) {
cordova.getActivity().runOnUiThread(r);
- return true;
+ return true;
} else if (action.equals(("generateShortUrl"))) {
if (args.length() != 3) {
- callbackContext.error(String.format("Parameter mismatched. 3 is required but %d is given", args.length()));
+ callbackContext.error(String.format("Parameter count mismatch"));
return false;
}
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("registerView")) {
if (args.length() != 1) {
- callbackContext.error(String.format("Parameter mismatched. 1 is required but %d is given", args.length()));
+ callbackContext.error(String.format("Parameter count mismatch"));
return false;
}
cordova.getActivity().runOnUiThread(r);
return true;
} else if (action.equals("showShareSheet")) {
if (args.length() < 3) {
- callbackContext.error(String.format("Parameter mismatched. 3 is required but %d is given", args.length()));
+ callbackContext.error(String.format("Parameter count mismatch"));
return false;
}
cordova.getActivity().runOnUiThread(r);
@@ -252,6 +231,13 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
branchObjectWrappers.set(args.getInt(0), branchObjWrapper);
+ } else if (action.equals("getBranchQRCode")) {
+ if (args.length() != 4) {
+ callbackContext.error(String.format("Parameter count mismatch"));
+ return false;
+ }
+ cordova.getActivity().runOnUiThread(r);
+ return true;
}
return true;
@@ -264,7 +250,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
return false;
}
-
+
public void crossPlatformIds(CallbackContext callbackContext) {
this.instance.getCrossPlatformIds(new BranchCPIDListener(callbackContext));
}
@@ -335,64 +321,6 @@ private void logout(CallbackContext callbackContext) {
}
- /**
- *
Redeems the specified number of credits from the "default" bucket, if there are sufficient
- * credits within it. If the number to redeem exceeds the number available in the bucket, all of
- * the available credits will be redeemed instead.
- *
- * @param value An {@link Integer} specifying the number of credits to attempt to redeem from
- * the bucket.
- * @param callbackContext A callback to execute at the end of this method
- */
- private void redeemRewards(final int value, CallbackContext callbackContext) {
-
- this.instance.redeemRewards(value, new RedeemRewardsListener(callbackContext));
-
- }
-
- /**
- *
Redeems the specified number of credits from the "default" bucket, if there are sufficient
- * credits within it. If the number to redeem exceeds the number available in the bucket, all of
- * the available credits will be redeemed instead.
- *
- * @param value An {@link Integer} specifying the number of credits to attempt to redeem from
- * the bucket.
- * @param bucket The name of the bucket to remove the credits from.
- * @param callbackContext A callback to execute at the end of this method
- */
- private void redeemRewards(int value, String bucket, CallbackContext callbackContext) {
-
- this.instance.redeemRewards(bucket, value, new RedeemRewardsListener(callbackContext));
-
- }
-
- /**
- *
Retrieves rewards for the current session, with a callback to perform a predefined
- * action following successful report of state change. You'll then need to call getCredits
- * in the callback to update the credit totals in your UX.
- *
- * @param callbackContext A callback to execute at the end of this method
- * @param bucket Load reward of a specific bucket
- */
- private void loadRewards(String bucket, CallbackContext callbackContext) {
-
- this.instance.loadRewards(new LoadRewardsListener(bucket, callbackContext, this.instance));
-
- }
-
- /**
- *
Retrieves rewards for the current session, with a callback to perform a predefined
- * action following successful report of state change. You'll then need to call getCredits
- * in the callback to update the credit totals in your UX.
- *
- * @param callbackContext A callback to execute at the end of this method
- */
- private void loadRewards(CallbackContext callbackContext) {
-
- this.instance.loadRewards(new LoadRewardsListener(callbackContext, this.instance));
-
- }
-
/**
*
Returns the parameters associated with the link that referred the session. If a user
* clicks a link, and then opens the app, initSession will return the paramters of the link
@@ -621,6 +549,70 @@ private void generateShortUrl(int instanceIdx, JSONObject options, JSONObject co
}
+ /**
+ * Generate a QR code.
+ *
+ * @param qrCodeSettings A {@link JSONObject} value to set QR cide options.
+ * @param instanceIdx The instance index from branchObjects array
+ * @param options A {@link JSONObject} value to set URL options.
+ * @param controlParams A {@link JSONObject} value to set the URL control parameters.
+ */
+ private void getBranchQRCode(JSONObject qrCodeSettings, int instanceIdx, JSONObject options, JSONObject controlParams, CallbackContext callbackContext) throws JSONException {
+
+ BranchLinkProperties linkProperties = createLinkProperties(options, controlParams);
+
+ BranchUniversalObjectWrapper branchUniversalWrapper = (BranchUniversalObjectWrapper) this.branchObjectWrappers.get(instanceIdx);
+ BranchUniversalObject buo = branchUniversalWrapper.branchUniversalObj;
+
+ BranchQRCode branchQRCode = new BranchQRCode();
+ if (qrCodeSettings.has("codeColor")) {
+ branchQRCode.setCodeColor(qrCodeSettings.getString("codeColor"));
+ }
+ if (qrCodeSettings.has("backgroundColor")) {
+ branchQRCode.setBackgroundColor(qrCodeSettings.getString("backgroundColor"));
+ }
+ if (qrCodeSettings.has("centerLogo")) {
+ branchQRCode.setCenterLogo(qrCodeSettings.getString("centerLogo"));
+ }
+ if (qrCodeSettings.has("width")) {
+ branchQRCode.setWidth(qrCodeSettings.getInt("width"));
+ }
+ if (qrCodeSettings.has("margin")) {
+ branchQRCode.setMargin(qrCodeSettings.getInt("margin"));
+ }
+ if (qrCodeSettings.has("imageFormat")) {
+ String imageFormat = qrCodeSettings.getString("imageFormat");
+ if (imageFormat != null ) {
+ if (imageFormat.equals("JPEG")) {
+ branchQRCode.setImageFormat(BranchQRCode.BranchImageFormat.JPEG);
+ } else {
+ branchQRCode.setImageFormat(BranchQRCode.BranchImageFormat.PNG);
+ }
+ }
+ }
+
+ try {
+ branchQRCode.getQRCodeAsData(this.activity, buo, linkProperties, new BranchQRCode.BranchQRCodeDataHandler() {
+ @Override
+ public void onSuccess(byte[] qrCodeData) {
+ String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT);
+ Log.d(LCAT, qrCodeString);
+ callbackContext.success(qrCodeString);
+ }
+
+ @Override
+ public void onFailure(Exception e) {
+ Log.d(LCAT, e.getMessage());
+ callbackContext.error(e.getMessage());
+ }
+ });
+ } catch (IOException e) {
+ e.printStackTrace();
+ Log.d(LCAT, e.getMessage());
+ callbackContext.error(e.getMessage());
+ }
+ }
+
/**
*
Sets the cookie based matching for all incoming requests.
*
If you want cookie based matching, call this before initUserSession