From 7838bf746a1c12c0c52d1ee68ddd6b93f726f10e Mon Sep 17 00:00:00 2001 From: Maxim Belov Date: Mon, 23 Nov 2020 16:20:15 +0200 Subject: [PATCH 01/37] use cdn for pod source url --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 87a6f95b..c8970bf5 100644 --- a/plugin.xml +++ b/plugin.xml @@ -84,7 +84,7 @@ SOFTWARE. - + From 0e9faefce802222e2a7f43e9317ee835a8da5e94 Mon Sep 17 00:00:00 2001 From: Maxim Belov Date: Thu, 29 Apr 2021 14:21:04 +0300 Subject: [PATCH 02/37] fix check exists branch.json --- src/scripts/npm/processConfigXml.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/scripts/npm/processConfigXml.js b/src/scripts/npm/processConfigXml.js index 0f208cd8..0c0eb6b8 100644 --- a/src/scripts/npm/processConfigXml.js +++ b/src/scripts/npm/processConfigXml.js @@ -104,8 +104,7 @@ let exists; try { - fs.existsSync(pathToBranchJson); - exists = true; + exists = fs.existsSync(pathToBranchJson); } catch(err) { exists = false; } From d6293e75751e782a0363be2b5686a98d2d087a96 Mon Sep 17 00:00:00 2001 From: Maxim Belov Date: Thu, 29 Apr 2021 16:00:50 +0300 Subject: [PATCH 03/37] fix duplicate alternate link domains --- src/scripts/__tests__/associatedDomains.test.js | 10 ++++++++++ src/scripts/android/updateAndroidManifest.js | 7 ++++++- src/scripts/ios/updateAssociatedDomains.js | 8 +++++++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/scripts/__tests__/associatedDomains.test.js diff --git a/src/scripts/__tests__/associatedDomains.test.js b/src/scripts/__tests__/associatedDomains.test.js new file mode 100644 index 00000000..6dd30779 --- /dev/null +++ b/src/scripts/__tests__/associatedDomains.test.js @@ -0,0 +1,10 @@ +const iosEntitlements = require('../ios/updateAssociatedDomains'); +const androidManifest = require('../android/updateAndroidManifest'); + +const preferences = { + iosLinkDomain: [], + androidLinkDomain: [], + linkDomain: ['cordova.app.link', 'cordova-alternate.app.link', 'test.app.link'] +} +console.log(iosEntitlements.updateAssociatedDomains(preferences)); +console.log(androidManifest.getAppLinkIntentFilterData(preferences)); diff --git a/src/scripts/android/updateAndroidManifest.js b/src/scripts/android/updateAndroidManifest.js index e14722cd..f2da6f76 100644 --- a/src/scripts/android/updateAndroidManifest.js +++ b/src/scripts/android/updateAndroidManifest.js @@ -6,7 +6,8 @@ // entry module.exports = { - writePreferences: writePreferences + writePreferences: writePreferences, + getAppLinkIntentFilterData: getAppLinkIntentFilterData }; // injects config.xml preferences into AndroidManifest.xml file. @@ -260,6 +261,10 @@ // app.link link domains need -alternate associated domains as well (for Deep Views) if (linkDomain.indexOf("app.link") !== -1) { + const isAlternateDomain = linkDomain.indexOf("-alternate") !== -1; + if(isAlternateDomain){ + continue; + } const first = linkDomain.split(".")[0]; const rest = linkDomain .split(".") diff --git a/src/scripts/ios/updateAssociatedDomains.js b/src/scripts/ios/updateAssociatedDomains.js index 4d54712f..b26547e9 100644 --- a/src/scripts/ios/updateAssociatedDomains.js +++ b/src/scripts/ios/updateAssociatedDomains.js @@ -12,7 +12,8 @@ // entry module.exports = { - addAssociatedDomains: addAssociatedDomains + addAssociatedDomains: addAssociatedDomains, + updateAssociatedDomains: updateAssociatedDomains }; // updates the associated domains from the link-domain field of the app's config.xml @@ -127,6 +128,11 @@ for (let i = 0; i < linkDomains.length; i++) { const linkDomain = linkDomains[i]; + const isAlternateDomain = linkDomain.indexOf("-alternate") !== -1; + if(isAlternateDomain){ + continue; + } + // add link domain to associated domain domainList.push(prefix + linkDomain); From 4690f467690ca7abe408062cffbfb752a12b4eb4 Mon Sep 17 00:00:00 2001 From: Ernest Cho Date: Thu, 29 Apr 2021 20:43:47 -0700 Subject: [PATCH 04/37] CORE-1890 update Android SDK to 5.0.8 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- plugin.xml | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55df6eac..6d28f257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +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/package.json b/package.json index 7e8a2790..8fd79095 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": "4.2.3", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.xml b/plugin.xml index 87a6f95b..10b78216 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="4.2.3"> branch-cordova-sdk @@ -63,7 +63,7 @@ SOFTWARE. - + From d03639b61dce1db77458c750877910bd6f2f1184 Mon Sep 17 00:00:00 2001 From: Ernest Cho Date: Mon, 3 May 2021 10:08:29 -0700 Subject: [PATCH 05/37] CORE-1898 correct signature as a quick fix. --- src/ios/BranchSDK.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index 8bd5685f..0d0bab17 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -796,7 +796,7 @@ - (void)lastAttributedTouchData:(CDVInvokedUrlCommand *)command { NSMutableDictionary *json = [NSMutableDictionary new]; Branch *branch = [self getInstance]; - [branch lastAttributedTouchDataWithAttributionWindow:30 completion:^(BranchLastAttributedTouchData * _Nullable latd) { + [branch lastAttributedTouchDataWithAttributionWindow:30 completion:^(BranchLastAttributedTouchData * _Nullable latd, NSError * _Nullable error) { CDVPluginResult* pluginResult = nil; if (latd) { [json setObject:latd.attributionWindow forKey:@"attribution_window"]; From 157ea450d42dad6d522ba5387fe17a2d319bee33 Mon Sep 17 00:00:00 2001 From: Ernest Cho Date: Mon, 3 May 2021 10:15:29 -0700 Subject: [PATCH 06/37] CORE-1898 prep patch release --- CHANGELOG.md | 6 ++++++ package.json | 2 +- plugin.xml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d28f257..8f40a52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +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 diff --git a/package.json b/package.json index 8fd79095..3202d864 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.3", + "version": "4.2.4", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.xml b/plugin.xml index e16265e9..c0a35a30 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="4.2.4"> branch-cordova-sdk From a3ba92bd6deae6600d19da96baa4a8c3b22d8031 Mon Sep 17 00:00:00 2001 From: hana-branch <44851763+hana-branch@users.noreply.github.com> Date: Fri, 10 Sep 2021 13:24:08 -0700 Subject: [PATCH 07/37] Update standard events list to the current version --- src/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 9dd1825f..58749527 100644 --- a/src/index.js +++ b/src/index.js @@ -16,15 +16,24 @@ const standardEvent = { STANDARD_EVENT_ADD_PAYMENT_INFO: "ADD_PAYMENT_INFO", STANDARD_EVENT_PURCHASE: "PURCHASE", STANDARD_EVENT_SPEND_CREDITS: "SPEND_CREDITS", + STANDARD_EVENT_CLICK_AD: "CLICK_AD", + STANDARD_EVENT_RESERVE: "RESERVE", + STANDARD_EVENT_VIEW_AD: "VIEW_AD", STANDARD_EVENT_SEARCH: "SEARCH", STANDARD_EVENT_VIEW_ITEM: "VIEW_ITEM", STANDARD_EVENT_VIEW_ITEMS: "VIEW_ITEMS", STANDARD_EVENT_RATE: "RATE", STANDARD_EVENT_SHARE: "SHARE", + STANDARD_EVENT_INITIATE_STREAM: "INITIATE_STREAM", + STANDARD_EVENT_COMPLETE_STREAM: "COMPLETE_STREAM", STANDARD_EVENT_COMPLETE_REGISTRATION: "COMPLETE_REGISTRATION", STANDARD_EVENT_COMPLETE_TUTORIAL: "COMPLETE_TUTORIAL", STANDARD_EVENT_ACHIEVE_LEVEL: "ACHIEVE_LEVEL", - STANDARD_EVENT_UNLOCK_ACHIEVEMENT: "UNLOCK_ACHIEVEMENT" + STANDARD_EVENT_UNLOCK_ACHIEVEMENT: "UNLOCK_ACHIEVEMENT", + STANDARD_EVENT_INVITE: "INVITE", + STANDARD_EVENT_LOGIN: "LOGIN", + STANDARD_EVENT_SUBSCRIBE: "SUBSCRIBE", + STANDARD_EVENT_START_TRIAL: "START_TRIAL" } // Branch prototype From 7acbd43e6d009c523fa852e94579db939b7be224 Mon Sep 17 00:00:00 2001 From: Nipun Date: Mon, 20 Sep 2021 16:03:09 -0700 Subject: [PATCH 08/37] Removed credit related methods Removed any methods involving credits --- src/__tests__/index.js | 89 +------ src/android/io/branch/BranchSDK.java | 227 ------------------ src/index.js | 19 -- src/ios/BranchSDK.h | 5 - src/ios/BranchSDK.m | 86 ------- .../examples/templates/cordova1/index.html | 11 - .../examples/templates/cordova1/index.js | 49 ---- 7 files changed, 1 insertion(+), 485 deletions(-) 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 c22f371f..cc072b07 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -170,19 +170,6 @@ 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())); @@ -305,64 +292,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 @@ -852,18 +781,6 @@ public void sendBranchEvent(String eventName, JSONObject metaData, CallbackConte //callbackContext.success(); } - /** - *

Gets the credit history of the specified bucket and triggers a callback to handle the - * response.

- * - * @param callbackContext A callback to execute at the end of this method - */ - private void getCreditHistory(CallbackContext callbackContext) { - - this.instance.getCreditHistory(new CreditHistoryListener(callbackContext)); - - } - /** * @access protected * @class BranchUniversalObjectWrapper @@ -1097,78 +1014,6 @@ public void onRegisterViewFinished(boolean registered, BranchError error) { } } - protected class LoadRewardsListener implements Branch.BranchReferralStateChangedListener { - private CallbackContext _callbackContext; - private Branch _instance; - private String _bucket; - - public LoadRewardsListener(String bucket, CallbackContext callbackContext, Branch instance) { - this._callbackContext = callbackContext; - this._instance = instance; - this._bucket = bucket; - } - - public LoadRewardsListener(CallbackContext callbackContext, Branch instance) { - this._callbackContext = callbackContext; - this._instance = instance; - this._bucket = ""; - } - - // Listener that implements BranchReferralStateChangedListener for loadRewards - @Override - public void onStateChanged(boolean changed, BranchError error) { - if (error == null) { - - int credits = 0; - - if (this._bucket.length() > 0) { - credits = this._instance.getCreditsForBucket(this._bucket); - } else { - credits = this._instance.getCredits(); - } - - this._callbackContext.success(credits); - - } else { - - String errorMessage = error.getMessage(); - - Log.d(LCAT, errorMessage); - - this._callbackContext.error(errorMessage); - - } - - } - } - - protected class RedeemRewardsListener implements Branch.BranchReferralStateChangedListener { - private CallbackContext _callbackContext; - - // Constructor that takes in a required callbackContext object - public RedeemRewardsListener(CallbackContext callbackContext) { - this._callbackContext = callbackContext; - } - - // Listener that implements BranchReferralStateChangedListener for redeemRewards - @Override - public void onStateChanged(boolean changed, BranchError error) { - - if (error == null) { - - this._callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, /* send boolean: is changed */ changed)); - - } else { - - String errorMessage = error.getMessage(); - - Log.d(LCAT, errorMessage); - - this._callbackContext.error(errorMessage); - } - } - } - protected class GenerateShortUrlListener implements Branch.BranchLinkCreateListener { private CallbackContext _callbackContext; @@ -1342,64 +1187,6 @@ public void onChannelSelected(String channelName) { } } - protected class CreditHistoryListener implements Branch.BranchListResponseListener { - private CallbackContext _callbackContext; - - // Constructor that takes in a required callbackContext object - public CreditHistoryListener(CallbackContext callbackContext) { - this._callbackContext = callbackContext; - } - - // Listener that implements BranchListResponseListener for getCreditHistory() - @Override - public void onReceivingResponse(JSONArray list, BranchError error) { - - ArrayList errors = new ArrayList(); - - if (error == null) { - - JSONArray data = new JSONArray(); - - if (list != null) { - - for (int i = 0, limit = list.length(); i < limit; ++i) { - - JSONObject entry; - - try { - entry = list.getJSONObject(i); - data.put(entry); - } catch (JSONException e) { - e.printStackTrace(); - errors.add(e.getMessage()); - } - - } - - } - - if (errors.size() > 0) { - StringBuilder sb = new StringBuilder(); - for (String s : errors) { - sb.append(s); - sb.append("\n"); - } - this._callbackContext.error(sb.toString()); - } else { - this._callbackContext.success(data); - } - } else { - - String errorMessage = error.getMessage(); - - Log.d(LCAT, errorMessage); - - this._callbackContext.error(errorMessage); - - } - } - } - protected class RunnableThread implements Runnable { private String action; @@ -1449,20 +1236,6 @@ public void run() { getLatestReferringParams(this.callbackContext); } else if (this.action.equals("logout")) { logout(this.callbackContext); - } else if (this.action.equals("loadRewards")) { - if (this.args.length() == 1) { - loadRewards(this.args.getString(0), this.callbackContext); - } else { - loadRewards(this.callbackContext); - } - } else if (this.action.equals("redeemRewards")) { - if (this.args.length() == 1) { - redeemRewards(this.args.getInt(0), this.callbackContext); - } else if (this.args.length() == 2) { - redeemRewards(this.args.getInt(0), this.args.getString(1), this.callbackContext); - } - } else if (this.action.equals("getCreditHistory")) { - getCreditHistory(this.callbackContext); } else if (this.action.equals("createBranchUniversalObject")) { createBranchUniversalObject(this.args.getJSONObject(0), this.callbackContext); } else if (this.action.equals("crossPlatformIds")) { diff --git a/src/index.js b/src/index.js index 9dd1825f..8b22e8fb 100644 --- a/src/index.js +++ b/src/index.js @@ -15,7 +15,6 @@ const standardEvent = { STANDARD_EVENT_INITIATE_PURCHASE: "INITIATE_PURCHASE", STANDARD_EVENT_ADD_PAYMENT_INFO: "ADD_PAYMENT_INFO", STANDARD_EVENT_PURCHASE: "PURCHASE", - STANDARD_EVENT_SPEND_CREDITS: "SPEND_CREDITS", STANDARD_EVENT_SEARCH: "SEARCH", STANDARD_EVENT_VIEW_ITEM: "VIEW_ITEM", STANDARD_EVENT_VIEW_ITEMS: "VIEW_ITEMS", @@ -293,24 +292,6 @@ Branch.prototype.createBranchUniversalObject = function createBranchUniversalObj }); }; -Branch.prototype.loadRewards = function loadRewards(bucket) { - var output = !bucket ? "" : bucket; - return execute("loadRewards", [output]); -}; - -Branch.prototype.redeemRewards = function redeemRewards(value, bucket) { - var params = [value]; - if (bucket) { - params.push(bucket); - } - - return execute("redeemRewards", params); -}; - -Branch.prototype.creditHistory = function creditHistory() { - return execute("getCreditHistory"); -}; - Branch.prototype.crossPlatformIds = function crossPlatformIds() { return execute("crossPlatformIds"); }; diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index d1ca2c9c..86d83097 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -39,11 +39,6 @@ - (void)logout:(CDVInvokedUrlCommand*)command; - (void)delayInitToCheckForSearchAds:(CDVInvokedUrlCommand*)command; -// Branch Referral Reward System -- (void)loadRewards:(CDVInvokedUrlCommand*)command; -- (void)redeemRewards:(CDVInvokedUrlCommand*)command; -- (void)getCreditHistory:(CDVInvokedUrlCommand*)command; - // Branch Universal Object Methods - (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command; - (void)registerView:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index 0d0bab17..4144e96a 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -418,92 +418,6 @@ - (void)delayInitToCheckForSearchAds:(CDVInvokedUrlCommand*)command [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } -#pragma mark - Branch Referral Reward System - -- (void)loadRewards:(CDVInvokedUrlCommand*)command -{ - Branch *branch = [self getInstance]; - NSString *bucket = @""; - - if ([command.arguments count] == 1) { - bucket = [command.arguments objectAtIndex:0]; - } - - [branch loadRewardsWithCallback:^(BOOL changed, NSError *error) { - - CDVPluginResult* pluginResult = nil; - if(!error) { - int credits = 0; - - if ([bucket length]) { - credits = (int)[branch getCreditsForBucket:bucket]; - } else { - credits = (int)[branch getCredits]; - } - - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:credits]; - } - else { - NSLog(@"Load Rewards Error: %@", [error localizedDescription]); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; - } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; -} - -- (void)redeemRewards:(CDVInvokedUrlCommand*)command -{ - - NSInteger amount = ((NSNumber *)[command.arguments objectAtIndex:0]).integerValue; - Branch *branch = [self getInstance]; - - if ([command.arguments count] == 2) { - - NSString *bucket = [command.arguments objectAtIndex:1]; - - [branch redeemRewards:(NSInteger)amount forBucket:(NSString *)bucket callback:^(BOOL changed, NSError *error) { - CDVPluginResult* pluginResult = nil; - if (!error) { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:changed]; - } - else { - NSLog(@"Redeem Rewards Error: %@", [error localizedDescription]); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; - } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; - } else { - [branch redeemRewards:amount callback:^(BOOL changed, NSError *error) { - CDVPluginResult* pluginResult = nil; - if (!error) { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:changed]; - } - else { - NSLog(@"Redeem Rewards Error: %@", [error localizedDescription]); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; - } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; - } -} - -- (void)getCreditHistory:(CDVInvokedUrlCommand*)command -{ - Branch *branch = [self getInstance]; - - [branch getCreditHistoryWithCallback:^(NSArray *list, NSError *error) { - CDVPluginResult* pluginResult = nil; - if (!error) { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:list]; - } - else { - NSLog(@"Credit History Error: %@", [error localizedDescription]); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; - } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; -} - #pragma mark - Branch Universal Object Methods - (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command diff --git a/src/scripts/examples/templates/cordova1/index.html b/src/scripts/examples/templates/cordova1/index.html index bea1c0c6..f37f794e 100644 --- a/src/scripts/examples/templates/cordova1/index.html +++ b/src/scripts/examples/templates/cordova1/index.html @@ -52,17 +52,6 @@ -
- Branch Referral -
- - -
-
- - -
-
diff --git a/src/scripts/examples/templates/cordova1/index.js b/src/scripts/examples/templates/cordova1/index.js index da873783..74b3e9d4 100644 --- a/src/scripts/examples/templates/cordova1/index.js +++ b/src/scripts/examples/templates/cordova1/index.js @@ -29,10 +29,6 @@ var branchUser = document.getElementById("branchUser"); var branchLogout = document.getElementById("branchLogout"); var branchEvent = document.getElementById("branchEvent"); var branchCommerce = document.getElementById("branchCommerce"); -var branchReferralsReward = document.getElementById("branchReferralsReward"); -var branchReferralsLoad = document.getElementById("branchReferralsLoad"); -var branchReferralsRedeem = document.getElementById("branchReferralsRedeem"); -var branchReferralsHistory = document.getElementById("branchReferralsHistory"); // handle DOM branchUniversalObject.addEventListener("click", BranchUniversalObject); @@ -46,10 +42,6 @@ branchUser.addEventListener("click", BranchUser); branchLogout.addEventListener("click", BranchLogout); branchEvent.addEventListener("click", BranchEvent); branchCommerce.addEventListener("click", BranchCommerce); -branchReferralsReward.addEventListener("click", BranchReferralsReward); -branchReferralsLoad.addEventListener("click", BranchReferralsLoad); -branchReferralsRedeem.addEventListener("click", BranchReferralsRedeem); -branchReferralsHistory.addEventListener("click", BranchReferralsHistory); // run app.initialize(); @@ -353,44 +345,3 @@ function BranchSpotlight() { logger(err, true); }); } - -function BranchReferralsReward() { - Branch.userCompletedAction("add5credits") - .then(function success(res) { - logger(res); - }) - .catch(function error(err) { - logger(err, true); - }); -} - -function BranchReferralsLoad() { - Branch.loadRewards() - .then(function success(res) { - logger(res); - }) - .catch(function error(err) { - logger(err, true); - }); -} - -function BranchReferralsRedeem() { - var amount = 10; - Branch.redeemRewards(amount) - .then(function success(res) { - logger(res); - }) - .catch(function error(err) { - logger(err, true); - }); -} - -function BranchReferralsHistory() { - Branch.creditHistory() - .then(function success(res) { - logger(res); - }) - .catch(function error(err) { - logger(err, true); - }); -} From b2725c593b3df12d46fd59db0f36bb51d3aba33f Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Tue, 11 Jan 2022 09:55:17 -0800 Subject: [PATCH 09/37] Add content items support in sendBranchEvent Add content items support in sendBranchEvent Fix bug where custom data would clobber other fields when creating event Remove sendCommerceEvent Update iOS SDK to 1.40.2 Update Android SDK to 5.0.15 --- package.json | 2 +- plugin.xml | 6 +- src/android/io/branch/BranchSDK.java | 165 +++++++++------------------ src/ios/BranchSDK.m | 94 ++------------- 4 files changed, 70 insertions(+), 197 deletions(-) diff --git a/package.json b/package.json index 3202d864..caae672b 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.4", + "version": "5.0.0", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.xml b/plugin.xml index c0a35a30..f56af327 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="5.0.0"> branch-cordova-sdk @@ -63,7 +63,7 @@ SOFTWARE. - + @@ -87,7 +87,7 @@ SOFTWARE. - +
diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index cc072b07..3818cd90 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -1,16 +1,15 @@ 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 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; @@ -20,22 +19,18 @@ 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.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 { static class BranchLinkProperties extends io.branch.referral.util.LinkProperties { @@ -147,13 +142,6 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo } 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())); - 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())); @@ -627,91 +615,6 @@ private void userCompletedAction(String action, JSONObject metaData, CallbackCon } - /** - *

A void call to indicate that the user has performed a specific commerce event and for that to be - * reported to the Branch API.

- * - * @param action A {@link String} value to be passed as an commerce event that the user has - * carried out. - * @param metaData A {@link JSONObject} containing app-defined meta-data to be attached to a - * user action that has just been completed. - * @param callbackContext A callback to execute at the end of this method - */ - private void sendCommerceEvent(JSONObject action, JSONObject metaData, CallbackContext callbackContext) throws JSONException { - - CommerceEvent commerce = new CommerceEvent(); - Iterator keys = action.keys(); - while (keys.hasNext()) { - String key = keys.next(); - String val; - try { - val = action.getString(key); - } catch (JSONException e) { - e.printStackTrace(); - callbackContext.error("Invalid key-value for " + key); - return; - } - if (key.equals("revenue")) { - commerce.setRevenue(Double.parseDouble(val)); - } else if (key.equals("currency")) { - commerce.setCurrencyType(CurrencyType.values()[Integer.parseInt(val)]); - } else if (key.equals("transactionID")) { - commerce.setTransactionID(val); - } else if (key.equals("coupon")) { - commerce.setCoupon(val); - } else if (key.equals("shipping")) { - commerce.setShipping(Double.parseDouble(val)); - } else if (key.equals("tax")) { - commerce.setTax(Double.parseDouble(val)); - } else if (key.equals("affiliation")) { - commerce.setAffiliation(val); - } else if (key.equals("products")) { - JSONArray products = new JSONArray(); - try { - products = action.getJSONArray(key); - } catch (JSONException e) { - e.printStackTrace(); - callbackContext.error("Invalid key-value for " + key); - return; - } - for (int i = 0; i < products.length(); ++i) { - Product product = new Product(); - JSONObject item = products.getJSONObject(i); - keys = item.keys(); - while (keys.hasNext()) { - key = keys.next(); - try { - val = item.getString(key); - } catch (JSONException e) { - e.printStackTrace(); - callbackContext.error("Invalid key-value for product for " + key); - return; - } - if (key.equals("sku")) { - product.setSku(val); - } else if (key.equals("name")) { - product.setName(val); - } else if (key.equals("price")) { - product.setPrice(Double.parseDouble(val)); - } else if (key.equals("quantity")) { - product.setQuantity(Integer.parseInt(val)); - } else if (key.equals("brand")) { - product.setBrand(val); - } else if (key.equals("category")) { - product.setCategory(ProductCategory.values()[Integer.parseInt(val)]); - } else if (key.equals("variant")) { - product.setVariant(val); - } - } - commerce.addProduct(product); - } - } - } - - this.instance.sendCommerceEvent(commerce, metaData, new BranchViewEventsListener(callbackContext)); - - } - public void sendBranchEvent(String eventName, CallbackContext callbackContext) throws JSONException { BranchEvent event; @@ -768,12 +671,19 @@ public void sendBranchEvent(String eventName, JSONObject metaData, CallbackConte event.setCustomerEventAlias(metaData.getString("customerEventAlias")); } else if (key.equals("customData")) { JSONObject customData = metaData.getJSONObject("customData"); - keys = customData.keys(); + Iterator customDataKeys = customData.keys(); - while (keys.hasNext()) { - String keyValue = (String) keys.next(); + while (customDataKeys.hasNext()) { + String keyValue = (String) customDataKeys.next(); event.addCustomDataProperty(keyValue, customData.getString(keyValue)); } + } else if (key.equals("contentMetadata")) { + JSONArray contentMetadata = metaData.getJSONArray("contentMetadata"); + for (int i = 0; i < contentMetadata.length(); i++) { + JSONObject item = contentMetadata.getJSONObject(i); + BranchUniversalObject universalObject = this.getContentItem(item); + event.addContentItems(universalObject); + } } } @@ -781,6 +691,47 @@ public void sendBranchEvent(String eventName, JSONObject metaData, CallbackConte //callbackContext.success(); } + private BranchUniversalObject getContentItem(JSONObject item) throws JSONException { + BranchUniversalObject universalObject = new BranchUniversalObject(); + ContentMetadata contentMetadata = new ContentMetadata(); + Iterator keys = item.keys(); + while (keys.hasNext()) { + String key = keys.next(); + + switch (key) { + case "quantity": + contentMetadata.setQuantity(Double.parseDouble(item.getString(key))); + break; + case "price": + contentMetadata.price = Double.parseDouble(item.getString(key)); + break; + case "currency": + String currencyString = item.getString(key); + CurrencyType currency = CurrencyType.getValue(currencyString); + if (currency != null) { + contentMetadata.currencyType = currency; + } + break; + case "productName": + contentMetadata.setProductName(item.getString(key)); + break; + case "productBrand": + contentMetadata.setProductBrand(item.getString(key)); + break; + case "sku": + contentMetadata.setSku(item.getString(key)); + break; + default: + contentMetadata.addCustomMetadata(key, item.getString(key)); + break; + } + } + + universalObject.setContentMetadata(contentMetadata); + + return universalObject; + } + /** * @access protected * @class BranchUniversalObjectWrapper @@ -1222,8 +1173,6 @@ public void run() { } else if (this.args.length() == 1) { userCompletedAction(this.args.getString(0), this.callbackContext); } - } else if (this.action.equals("sendCommerceEvent")) { - sendCommerceEvent(this.args.getJSONObject(0), this.args.getJSONObject(1), this.callbackContext); } else if (this.action.equals("sendBranchEvent")) { if (this.args.length() == 2) { sendBranchEvent(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext); diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index 4144e96a..278426a2 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -301,95 +301,19 @@ -(void)sendBranchEvent:(CDVInvokedUrlCommand*)command else if ([key isEqualToString:@"customData"] && [[metadata objectForKey:key] isKindOfClass:[NSMutableDictionary class]]) { event.customData = [metadata objectForKey:key]; } + else if ([key isEqualToString:@"contentMetadata"]){ + NSMutableArray *mArray = [[NSMutableArray alloc]init]; + + for (NSDictionary *dataDictionary in [metadata objectForKey:key]){ + BranchUniversalObject *contentItem = [BranchUniversalObject objectWithDictionary:(dataDictionary)]; + [mArray addObject:contentItem]; + } + event.contentItems = [mArray copy]; + } } [event logEvent]; } -- (void)sendCommerceEvent:(CDVInvokedUrlCommand*)command -{ - NSDictionary *data = [command.arguments objectAtIndex:0]; - NSDictionary *metadata; - BNCCommerceEvent *commerce = [[BNCCommerceEvent alloc] init]; - NSArray *categories = [NSArray arrayWithObjects:BNCProductCategoryAnimalSupplies, BNCProductCategoryApparel, BNCProductCategoryArtsEntertainment, BNCProductCategoryBabyToddler, BNCProductCategoryBusinessIndustrial, BNCProductCategoryCamerasOptics, BNCProductCategoryElectronics, BNCProductCategoryFoodBeverageTobacco, BNCProductCategoryFurniture, BNCProductCategoryHardware, BNCProductCategoryHealthBeauty, BNCProductCategoryHomeGarden, BNCProductCategoryLuggageBags, BNCProductCategoryMature, BNCProductCategoryMedia, BNCProductCategoryOfficeSupplies, BNCProductCategoryReligious, BNCProductCategorySoftware, BNCProductCategorySportingGoods, BNCProductCategoryToysGames, BNCProductCategoryVehiclesParts, nil]; - NSArray *currencies = [NSArray arrayWithObjects:@"AED", @"AFN", @"ALL", @"AMD", @"ANG", @"AOA", @"ARS", @"AUD", @"AWG", @"AZN", @"BAM", @"BBD", @"BDT", @"BGN", @"BHD", @"BIF", @"BMD", @"BND", @"BOB", @"BOV", @"BRL", @"BSD", @"BTN", @"BWP", @"BYN", @"BYR", @"BZD", @"CAD", @"CDF", @"CHE", @"CHF", @"CHW", @"CLF", @"CLP", @"CNY", @"COP", @"COU", @"CRC", @"CUC", @"CUP", @"CVE", @"CZK", @"DJF", @"DKK", @"DOP", @"DZD", @"EGP", @"ERN", @"ETB", @"EUR", @"FJD", @"FKP", @"GBP", @"GEL", @"GHS", @"GIP", @"GMD", @"GNF", @"GTQ", @"GYD", @"HKD", @"HNL", @"HRK", @"HTG", @"HUF", @"IDR", @"ILS", @"INR", @"IQD", @"IRR", @"ISK", @"JMD", @"JOD", @"JPY", @"KES", @"KGS", @"KHR", @"KMF", @"KPW", @"KRW", @"KWD", @"KYD", @"KZT", @"LAK", @"LBP", @"LKR", @"LRD", @"LSL", @"LYD", @"MAD", @"MDL", @"MGA", @"MKD", @"MMK", @"MNT", @"MOP", @"MRO", @"MUR", @"MVR", @"MWK", @"MXN", @"MXV", @"MYR", @"MZN", @"NAD", @"NGN", @"NIO", @"NOK", @"NPR", @"NZD", @"OMR", @"PAB", @"PEN", @"PGK", @"PHP", @"PKR", @"PLN", @"PYG", @"QAR", @"RON", @"RSD", @"RUB", @"RWF", @"SAR", @"SBD", @"SCR", @"SDG", @"SEK", @"SGD", @"SHP", @"SLL", @"SOS", @"SRD", @"SSP", @"STD", @"SYP", @"SZL", @"THB", @"TJS", @"TMT", @"TND", @"TOP", @"TRY", @"TTD", @"TWD", @"TZS", @"UAH", @"UGX", @"USD", @"USN", @"UYI", @"UYU", @"UZS", @"VEF", @"VND", @"VUV", @"WST", @"XAF", @"XAG", @"XAU", @"XBA", @"XBB", @"XBC", @"XBD", @"XCD", @"XDR", @"XFU", @"XOF", @"XPD", @"XPF", @"XPT", @"XSU", @"XTS", @"XUA", @"XXX", @"YER", @"ZAR", @"ZMW", nil]; - - if ([command.arguments count] == 2) { - metadata = [command.arguments objectAtIndex:1]; - } - - for (id key in data) { - if ([key isEqualToString:@"revenue"]) { - NSString *value = ([[data objectForKey:key] isKindOfClass:[NSString class]]) ? [data objectForKey:key] : [[data objectForKey:key] stringValue]; - commerce.revenue = [NSDecimalNumber decimalNumberWithString:value]; - } - else if ([key isEqualToString:@"currency"]) { - NSString *value = ([[data objectForKey:key] isKindOfClass:[NSString class]]) ? [data objectForKey:key] : [[data objectForKey:key] stringValue]; - commerce.currency = [currencies objectAtIndex:[value intValue]]; - } - else if ([key isEqualToString:@"transactionID"]) { - commerce.transactionID = [data objectForKey:key]; - } - else if ([key isEqualToString:@"shipping"]) { - NSString *value = ([[data objectForKey:key] isKindOfClass:[NSString class]]) ? [data objectForKey:key] : [[data objectForKey:key] stringValue]; - commerce.shipping = [NSDecimalNumber decimalNumberWithString:value]; - } - else if ([key isEqualToString:@"tax"]) { - NSString *value = ([[data objectForKey:key] isKindOfClass:[NSString class]]) ? [data objectForKey:key] : [[data objectForKey:key] stringValue]; - commerce.tax = [NSDecimalNumber decimalNumberWithString:value]; - } - else if ([key isEqualToString:@"coupon"]) { - commerce.coupon = [data objectForKey:key]; - } - else if ([key isEqualToString:@"affiliation"]) { - commerce.affiliation = [data objectForKey:key]; - } - else if ([key isEqualToString:@"products"] && [[data objectForKey:key] isKindOfClass:[NSArray class]]) { - NSMutableArray *products = [[NSMutableArray alloc] init]; - NSArray *dataProducts = [data objectForKey:key]; - for (NSDictionary *dataDictionary in dataProducts) { - BNCProduct *product = [[BNCProduct alloc] init]; - for (id key in dataDictionary) { - if ([key isEqualToString:@"sku"]) { - product.sku = [dataDictionary objectForKey:key]; - } - else if ([key isEqualToString:@"name"]) { - product.name = [dataDictionary objectForKey:key]; - } - else if ([key isEqualToString:@"price"]) { - NSString *value = ([[dataDictionary objectForKey:key] isKindOfClass:[NSString class]]) ? [dataDictionary objectForKey:key] : [[dataDictionary objectForKey:key] stringValue]; - product.price = [NSDecimalNumber decimalNumberWithString:value]; - } - else if ([key isEqualToString:@"quantity"]) { - NSString *value = ([[dataDictionary objectForKey:key] isKindOfClass:[NSString class]]) ? [dataDictionary objectForKey:key] : [[dataDictionary objectForKey:key] stringValue]; - product.quantity = [NSNumber numberWithInt:[value intValue]]; - } - else if ([key isEqualToString:@"brand"]) { - product.brand = [dataDictionary objectForKey:key]; - } - else if ([key isEqualToString:@"category"]) { - NSString *value = ([[dataDictionary objectForKey:key] isKindOfClass:[NSString class]]) ? [dataDictionary objectForKey:key] : [[dataDictionary objectForKey:key] stringValue]; - product.category = [categories objectAtIndex:[value intValue]]; - } - else if ([key isEqualToString:@"variant"]) { - product.variant = [dataDictionary objectForKey:key]; - } - } - [products addObject:product]; - } - commerce.products = products; - } - } - - [[Branch getInstance] sendCommerceEvent:commerce metadata:metadata withCompletion:^(NSDictionary *response, NSError *error) { - CDVPluginResult *pluginResult = nil; - if (!error) { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString: @"Success"]; - } else { - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; - } - [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; - }]; -} - (void)logout:(CDVInvokedUrlCommand*)command { From 901dbf0cf6565b51ec6b759e33e270596ea827a0 Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Tue, 8 Feb 2022 12:52:32 -0800 Subject: [PATCH 10/37] Remove request package --- CHANGELOG.md | 10 ++++++++++ package.json | 3 +-- plugin.xml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f40a52c..9c4832e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +5.0.1 February 8, 2022 +* Remove request package (thanks for catching Sujay-shetty) + +5.0.0 +* 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 diff --git a/package.json b/package.json index caae672b..4fd75ee9 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": "5.0.0", + "version": "5.0.1", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", @@ -60,7 +60,6 @@ "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" diff --git a/plugin.xml b/plugin.xml index f56af327..9fe8b122 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="5.0.1"> branch-cordova-sdk From 6d697a572557a7d1d8001c92d14bfc8dc21ccd16 Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Tue, 8 Feb 2022 12:54:19 -0800 Subject: [PATCH 11/37] trivial - add date to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c4832e1..e7dc24e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ 5.0.1 February 8, 2022 * Remove request package (thanks for catching Sujay-shetty) -5.0.0 +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 From 82b938b1332d6648cb3d055cad9c56f0a17c26c4 Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Wed, 9 Feb 2022 12:24:57 -0800 Subject: [PATCH 12/37] Update dependencies --- package.json | 24 ++++++++++++------------ plugin.xml | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 4fd75ee9..361a6018 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": "5.0.1", + "version": "5.0.2", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", @@ -56,22 +56,22 @@ }, "dependencies": { "fs": "0.0.1-security", - "glob": "^7.1.4", + "glob": "^7.2.0", "mkpath": "^1.0.0", - "node-version-compare": "^1.0.1", - "plist": "^3.0.1", - "shelljs": "^0.8.3", - "xcode": "^2.0.0", - "xml2js": "^0.4.19" + "node-version-compare": "^1.0.3", + "plist": "^3.0.4", + "shelljs": "^0.8.5", + "xcode": "^2.1.0", + "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" + "eslint-config-airbnb-base": "^14.2.1", + "eslint-plugin-import": "^2.25.2", + "husky": "^4.3.8", + "lint-staged": "^10.5.4", + "prettier": "^2.5.1" } } diff --git a/plugin.xml b/plugin.xml index 9fe8b122..082c059f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="5.0.2"> branch-cordova-sdk From cbb06dbd23f57602014abe23f780fb3042129d2a Mon Sep 17 00:00:00 2001 From: echo Date: Wed, 25 May 2022 21:47:48 -0700 Subject: [PATCH 13/37] Update dependencies --- package.json | 25 ++++++++++++------------- plugin.xml | 6 +++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 361a6018..ea065a22 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": "5.0.2", + "version": "5.1.0", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", @@ -55,23 +55,22 @@ ] }, "dependencies": { - "fs": "0.0.1-security", - "glob": "^7.2.0", + "glob": "^8.0.3", "mkpath": "^1.0.0", "node-version-compare": "^1.0.3", - "plist": "^3.0.4", + "plist": "^3.0.5", "shelljs": "^0.8.5", - "xcode": "^2.1.0", + "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.2.1", - "eslint-plugin-import": "^2.25.2", - "husky": "^4.3.8", - "lint-staged": "^10.5.4", - "prettier": "^2.5.1" + "@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 082c059f..626307c5 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="5.1.0"> branch-cordova-sdk @@ -63,7 +63,7 @@ SOFTWARE. - + @@ -87,7 +87,7 @@ SOFTWARE. - + From 4fbf0592591bab9538f46acbb3b6d8874ffa5724 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 27 May 2022 20:41:23 -0700 Subject: [PATCH 14/37] SDK-1440 fix logging method, update iOS SDK --- CHANGELOG.md | 9 +++++++++ package.json | 1 + plugin.xml | 2 +- src/index.js | 13 ++++++++++--- src/ios/BranchSDK.h | 2 +- src/ios/BranchSDK.m | 13 ++++--------- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7dc24e4..b4876085 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +5.1.0 May 27, 2022 +* Update iOS SDK to 1.42.0 +* Update Android SDK to 5.1.4 +* 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) diff --git a/package.json b/package.json index ea065a22..1f898058 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "xml2js": "^0.4.23" }, "devDependencies": { + "fs": "0.0.1-security", "@commitlint/cli": "^17.0.1", "@commitlint/config-conventional": "^17.0.0", "eslint": "^8.16.0", diff --git a/plugin.xml b/plugin.xml index 626307c5..9b8de90b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -87,7 +87,7 @@ SOFTWARE. - + diff --git a/src/index.js b/src/index.js index ec7db001..30768635 100644 --- a/src/index.js +++ b/src/index.js @@ -34,7 +34,7 @@ const standardEvent = { // Branch prototype var Branch = function Branch() { - this.debugMode = false; + this.enableLogging = false; this.trackingDisabled = false; this.sessionInitialized = false; }; @@ -113,11 +113,18 @@ Branch.prototype.setRequestMetadata = function setRequestMetadata(key, val) { return execute("setRequestMetadata", [key, val]); }; +// Deprecated. Replaced by setLogging(isEnabled) and test devices. https://help.branch.io/using-branch/docs/adding-test-devices Branch.prototype.setDebug = function setDebug(isEnabled) { + return new Promise(function promise(resolve, reject) { + resolve(false); + }); +}; + +Branch.prototype.setLogging = function setLogging(isEnabled) { var value = typeof isEnabled !== "boolean" ? false : isEnabled; - this.debugMode = value; + this.enableLogging = value; - return execute("setDebug", [value]); + return execute("enableLogging", [value]); }; Branch.prototype.setCookieBasedMatching = function setCookieBasedMatching( diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index 86d83097..bc52b107 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -29,7 +29,7 @@ - (void)enableTestMode:(CDVInvokedUrlCommand*)command; - (void)initSession:(CDVInvokedUrlCommand*)command; - (void)disableTracking:(CDVInvokedUrlCommand*)command; -- (void)setDebug:(CDVInvokedUrlCommand*)command; +- (void)enableLogging:(CDVInvokedUrlCommand*)command; - (void)getAutoInstance:(CDVInvokedUrlCommand*)command; - (void)getLatestReferringParams:(CDVInvokedUrlCommand*)command; - (void)getFirstReferringParams:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index 278426a2..ece51e1c 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -86,11 +86,6 @@ - (void)continueUserActivity:(CDVInvokedUrlCommand*)command #pragma mark - Public APIs #pragma mark - Branch Basic Methods -- (void)enableTestMode:(CDVInvokedUrlCommand*)command -{ - [Branch setUseTestBranchKey:TRUE]; -} - - (void)initSession:(CDVInvokedUrlCommand*)command { [[Branch getInstance] registerPluginName:@"CordovaIonic" version:pluginVersion]; @@ -153,11 +148,11 @@ - (void)disableTracking:(CDVInvokedUrlCommand*)command [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } -- (void)setDebug:(CDVInvokedUrlCommand*)command +- (void)enableLogging:(CDVInvokedUrlCommand*)command { - bool enableDebug = [[command.arguments objectAtIndex:0] boolValue]; - if (enableDebug) { - [[Branch getInstance] setDebug]; + bool enableLogging = [[command.arguments objectAtIndex:0] boolValue]; + if (enableLogging) { + [[Branch getInstance] enableLogging]; } CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:enableDebug]; From c4d67c1abbce2e407fef2b0188adc7710d502fde Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 27 May 2022 20:42:47 -0700 Subject: [PATCH 15/37] SDK-1440 revert removal of enableTestMode on iOS --- src/ios/BranchSDK.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index ece51e1c..31d3c040 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -86,6 +86,11 @@ - (void)continueUserActivity:(CDVInvokedUrlCommand*)command #pragma mark - Public APIs #pragma mark - Branch Basic Methods +- (void)enableTestMode:(CDVInvokedUrlCommand*)command +{ + [Branch setUseTestBranchKey:TRUE]; +} + - (void)initSession:(CDVInvokedUrlCommand*)command { [[Branch getInstance] registerPluginName:@"CordovaIonic" version:pluginVersion]; From e4b705cf4a1e23e3a9cb0dc82085ff3af86180b5 Mon Sep 17 00:00:00 2001 From: echo Date: Fri, 27 May 2022 21:44:33 -0700 Subject: [PATCH 16/37] SDK-1440 enable android logging. Fix issue with iOS logging. Add note about early lifecycle events prior to JS runtime init --- src/android/io/branch/BranchSDK.java | 14 +++++++++----- src/index.js | 1 + src/ios/BranchSDK.m | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 3818cd90..ca898f3a 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -527,15 +527,19 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC } /** - *

Sets the library to function in debug mode, enabling logging of all requests.

- *

If you want to flag debug, call this before initUserSession

+ *

Enabling Branch SDK logging

* - * @param isEnable A {@link Boolean} value to enable/disable debugging mode for the app. + * @param isEnable A {@link Boolean} value to enable/disable logging * @param callbackContext A callback to execute at the end of this method */ - private void setDebug(boolean isEnable, CallbackContext callbackContext) { + private void setLogging(boolean isEnable, CallbackContext callbackContext) { this.activity = this.cordova.getActivity(); - Branch.enableDebugMode(); + if (isEnable == true) { + Branch.enableLogging(); + } else { + Branch.disableLogging(); + } + callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, isEnable)); } diff --git a/src/index.js b/src/index.js index 30768635..05b03757 100644 --- a/src/index.js +++ b/src/index.js @@ -120,6 +120,7 @@ Branch.prototype.setDebug = function setDebug(isEnabled) { }); }; +// For early lifecycle logging, we recommend you enable logging in the native iOS or Android code. Branch.prototype.setLogging = function setLogging(isEnabled) { var value = typeof isEnabled !== "boolean" ? false : isEnabled; this.enableLogging = value; diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index 31d3c040..ca38c9c7 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -160,7 +160,7 @@ - (void)enableLogging:(CDVInvokedUrlCommand*)command [[Branch getInstance] enableLogging]; } - CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:enableDebug]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:enableLogging]; [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } From e18d4898f471f9030be483b4e8428f2471a07d40 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 2 Jun 2022 09:34:52 -0700 Subject: [PATCH 17/37] SDK-1440 pick up android 5.1.5 --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 9b8de90b..07ca4aca 100644 --- a/plugin.xml +++ b/plugin.xml @@ -63,7 +63,7 @@ SOFTWARE. - + From 9cf229a31dcab191c54fa2cf1b895c864ec9e484 Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 2 Jun 2022 10:38:13 -0700 Subject: [PATCH 18/37] SDK-1440 update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4876085..9f4ccda1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ 5.1.0 May 27, 2022 * Update iOS SDK to 1.42.0 -* Update Android SDK to 5.1.4 +* 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 From c6fdb7fea9bf6d49d86d939f726070f75877c3ca Mon Sep 17 00:00:00 2001 From: echo Date: Thu, 2 Jun 2022 16:23:38 -0700 Subject: [PATCH 19/37] SDK-1440 update android logging method --- src/android/io/branch/BranchSDK.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index ca898f3a..97dddfd8 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -115,7 +115,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo Runnable r = new RunnableThread(action, args, callbackContext); - if (action.equals("setDebug")) { + if (action.equals("setLogging")) { cordova.getActivity().runOnUiThread(r); return true; } else if (action.equals("setCookieBasedMatching")) { @@ -1158,8 +1158,8 @@ public void run() { try { Log.d(LCAT, "Runnable: " + this.action); - if (this.action.equals("setDebug")) { - setDebug(this.args.getBoolean(0), this.callbackContext); + if (this.action.equals("setLogging")) { + setLogging(this.args.getBoolean(0), this.callbackContext); } else if (this.action.equals("setCookieBasedMatching")) { setCookieBasedMatching(this.args.getString(0), this.callbackContext); } else if (this.action.equals("disableTracking")) { From 304ecd0842421cd2dcc28b461fe5a6ecafdba431 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Tue, 19 Jul 2022 18:23:31 -0700 Subject: [PATCH 20/37] iOS and Initial Android functions --- package.json | 2 +- plugin.xml | 4 +- src/android/io/branch/BranchSDK.java | 42 +++++++++ src/index.js | 26 +++++- src/ios/BranchSDK.m | 127 +++++++++++++++++++++++++++ 5 files changed, 197 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1f898058..245e90de 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": "5.1.0", + "version": "5.2.0", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.xml b/plugin.xml index 07ca4aca..5d746a60 100644 --- a/plugin.xml +++ b/plugin.xml @@ -63,7 +63,7 @@ SOFTWARE. - + @@ -87,7 +87,7 @@ SOFTWARE. - + diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 97dddfd8..289702be 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -223,6 +223,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo branchObjectWrappers.set(args.getInt(0), branchObjWrapper); + } else if (action.equals("getBranchQRCode")) { + cordova.getActivity().runOnUiThread(r); + return true; } return true; @@ -508,6 +511,45 @@ 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; + + try { + qrCode.getQRCodeAsData(getReactApplicationContext().getCurrentActivity(), branchUniversalObject, linkProperties, new BranchQRCode.BranchQRCodeDataHandler() { + @Override + public void onSuccess(byte[] qrCodeData) { + String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); + promise.resolve(qrCodeString); + } + + @Override + public void onFailure(Exception e) { + Log.d("Failed to get QR Code", e.getMessage()); + promise.reject("Failed to get QR Code", e.getMessage()); + } + }); + } catch (IOException e) { + e.printStackTrace(); + Log.d("Failed to get QR Code", e.getMessage()); + promise.reject("Failed to get QR Code", e.getMessage()); + } + + //branchUniversalWrapper.branchUniversalObj.generateShortUrl(this.activity, linkProperties, new GenerateShortUrlListener(callbackContext)); + + } + /** *

Sets the cookie based matching for all incoming requests.

*

If you want cookie based matching, call this before initUserSession

diff --git a/src/index.js b/src/index.js index 05b03757..eae03123 100644 --- a/src/index.js +++ b/src/index.js @@ -39,7 +39,7 @@ var Branch = function Branch() { this.sessionInitialized = false; }; -// JavsSript to SDK wrappers +// JavaScript to SDK wrappers function execute(method, params) { var output = !params ? [] : params; @@ -314,5 +314,29 @@ Branch.prototype.lastAttributedTouchData = function lastAttributedTouchData() { return execute("lastAttributedTouchData"); }; +Branch.prototype.getBranchQRCode = function getBranchQRCode( + qrCodeSettings, + branchUniversalObject, + analytics, + properties +) { + var args = []; + if (qrCodeSettings) { + args.push(qrCodeSettings); + } + if (branchUniversalObject) { + args.push(branchUniversalObject.instanceId); + } + if (analytics) { + args.push(analytics); + } + if (properties) { + args.push(properties); + } + + return execute("getBranchQRCode", args); +}; + + // export Branch object module.exports = new Branch(); diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index ca38c9c7..f5d4e5e7 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -648,6 +648,133 @@ - (void)lastAttributedTouchData:(CDVInvokedUrlCommand *)command { }]; } +- (void)getBranchQRCode:(CDVInvokedUrlCommand*)command +{ + int branchUniversalObjectId = [[command.arguments objectAtIndex:1] intValue]; + NSMutableDictionary *branchUniversalObjDict = [self.branchUniversalObjArray objectAtIndex:branchUniversalObjectId]; + BranchUniversalObject *branchUniversalObj = [branchUniversalObjDict objectForKey:@"branchUniversalObj"]; + //BranchUniversalObject *branchUniversalObj = [BranchUniversalObject new];//[[BranchUniversalObject alloc] initWithMap:universalObjectProperties]; + + BranchLinkProperties *linkProperties = [BranchLinkProperties new];//[self createLinkProperties:linkPropertiesMap withControlParams:controlParamsMap]; + + NSDictionary *arg1 = [command.arguments objectAtIndex:2]; + NSDictionary *arg2 = [command.arguments objectAtIndex:3]; + + for (id key in arg1) { + if ([key isEqualToString:@"duration"]) { + linkProperties.matchDuration = (NSUInteger)[((NSNumber *)[arg1 objectForKey:key]) integerValue]; + } + else if ([key isEqualToString:@"feature"]) { + linkProperties.feature = [arg1 objectForKey:key]; + } + else if ([key isEqualToString:@"stage"]) { + linkProperties.stage = [arg1 objectForKey:key]; + } + else if ([key isEqualToString:@"campaign"]) { + linkProperties.campaign = [arg1 objectForKey:key]; + } + else if ([key isEqualToString:@"alias"]) { + linkProperties.alias = [arg1 objectForKey:key]; + } + else if ([key isEqualToString:@"channel"]) { + linkProperties.channel = [arg1 objectForKey:key]; + } + else if ([key isEqualToString:@"tags"] && [[arg1 objectForKey:key] isKindOfClass:[NSArray class]]) { + linkProperties.tags = [arg1 objectForKey:key]; + } + } + if (arg2) { + for (id key in arg2) { + [linkProperties addControlParam:key withValue:[arg2 objectForKey:key]]; + } + } + + + NSMutableDictionary *qrCodeSettingsMap = [command.arguments objectAtIndex:0]; + + BranchQRCode *qrCode = [BranchQRCode new]; + + if (qrCodeSettingsMap[@"codeColor"]) { + qrCode.codeColor = [self colorWithHexString:qrCodeSettingsMap[@"codeColor"]]; + } + if (qrCodeSettingsMap[@"backgroundColor"]) { + qrCode.backgroundColor = [self colorWithHexString:qrCodeSettingsMap[@"backgroundColor"]]; + } + if (qrCodeSettingsMap[@"centerLogo"]) { + qrCode.centerLogo = qrCodeSettingsMap[@"centerLogo"]; + } + if (qrCodeSettingsMap[@"width"]) { + qrCode.width = qrCodeSettingsMap[@"width"]; + } + if (qrCodeSettingsMap[@"margin"]) { + qrCode.margin = qrCodeSettingsMap[@"margin"]; + } + if (qrCodeSettingsMap[@"imageFormat"]) { + if ([qrCodeSettingsMap[@"imageFormat"] isEqual:@"JPEG"]) { + qrCode.imageFormat = BranchQRCodeImageFormatJPEG; + } else { + qrCode.imageFormat = BranchQRCodeImageFormatPNG; + } + } + + [qrCode getQRCodeAsData:branchUniversalObj linkProperties:linkProperties completion:^(NSData * _Nonnull qrCodeData, NSError * _Nonnull error) { + CDVPluginResult* pluginResult = nil; + + if (!error) { + NSString* imageString = [qrCodeData base64EncodedStringWithOptions:nil]; + NSLog(@"Success"); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:imageString]; + } else { + NSLog(@"Error"); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} + +- (UIColor *) colorWithHexString: (NSString *) hexString { + NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#" withString: @""] uppercaseString]; + CGFloat alpha, red, blue, green; + switch ([colorString length]) { + case 3: // #RGB + alpha = 1.0f; + red = [self colorComponentFrom: colorString start: 0 length: 1]; + green = [self colorComponentFrom: colorString start: 1 length: 1]; + blue = [self colorComponentFrom: colorString start: 2 length: 1]; + break; + case 4: // #ARGB + alpha = [self colorComponentFrom: colorString start: 0 length: 1]; + red = [self colorComponentFrom: colorString start: 1 length: 1]; + green = [self colorComponentFrom: colorString start: 2 length: 1]; + blue = [self colorComponentFrom: colorString start: 3 length: 1]; + break; + case 6: // #RRGGBB + alpha = 1.0f; + red = [self colorComponentFrom: colorString start: 0 length: 2]; + green = [self colorComponentFrom: colorString start: 2 length: 2]; + blue = [self colorComponentFrom: colorString start: 4 length: 2]; + break; + case 8: // #AARRGGBB + alpha = [self colorComponentFrom: colorString start: 0 length: 2]; + red = [self colorComponentFrom: colorString start: 2 length: 2]; + green = [self colorComponentFrom: colorString start: 4 length: 2]; + blue = [self colorComponentFrom: colorString start: 6 length: 2]; + break; + default: + NSLog(@"Error: Invalid color value. It should be a hex value of the form #RBG, #ARGB, #RRGGBB, or #AARRGGBB"); + break; + } + return [UIColor colorWithRed: red green: green blue: blue alpha: alpha]; +} + +- (CGFloat) colorComponentFrom: (NSString *) string start: (NSUInteger) start length: (NSUInteger) length { + NSString *substring = [string substringWithRange: NSMakeRange(start, length)]; + NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring]; + unsigned hexComponent; + [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent]; + return hexComponent / 255.0; +} #pragma mark - URL Methods (not fully implemented YET!) From 6d7c7026609cbb835786edcdde18521985bd60f4 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Mon, 25 Jul 2022 18:01:00 -0700 Subject: [PATCH 21/37] Added basic android side --- ...onegap-branch-deep-linking-attribution.iml | 11 +++ src/android/io/branch/BranchSDK.java | 78 +++++++++++++++---- 2 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 cordova-ionic-phonegap-branch-deep-linking-attribution.iml diff --git a/cordova-ionic-phonegap-branch-deep-linking-attribution.iml b/cordova-ionic-phonegap-branch-deep-linking-attribution.iml new file mode 100644 index 00000000..93f7e2e2 --- /dev/null +++ b/cordova-ionic-phonegap-branch-deep-linking-attribution.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 289702be..72589f06 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -6,6 +6,7 @@ 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; @@ -16,6 +17,7 @@ import java.util.ArrayList; import java.util.Iterator; +import java.io.IOException; import io.branch.indexing.BranchUniversalObject; import io.branch.referral.Branch; @@ -24,6 +26,7 @@ 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; @@ -31,6 +34,7 @@ import io.branch.referral.util.CurrencyType; import io.branch.referral.util.ShareSheetStyle; + public class BranchSDK extends CordovaPlugin { static class BranchLinkProperties extends io.branch.referral.util.LinkProperties { @@ -526,26 +530,36 @@ private void getBranchQRCode(JSONObject qrCodeSettings, int instanceIdx, JSONObj BranchUniversalObjectWrapper branchUniversalWrapper = (BranchUniversalObjectWrapper) this.branchObjectWrappers.get(instanceIdx); BranchUniversalObject buo = branchUniversalWrapper.branchUniversalObj; + BranchQRCode qrCode = new BranchQRCode(); + //setCodeColor, setWidth, etc. + try { - qrCode.getQRCodeAsData(getReactApplicationContext().getCurrentActivity(), branchUniversalObject, linkProperties, new BranchQRCode.BranchQRCodeDataHandler() { - @Override - public void onSuccess(byte[] qrCodeData) { - String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); - promise.resolve(qrCodeString); - } - - @Override - public void onFailure(Exception e) { - Log.d("Failed to get QR Code", e.getMessage()); - promise.reject("Failed to get QR Code", e.getMessage()); - } - }); + qrCode.getQRCodeAsData(this.activity, buo, linkProperties, new GetBranchQRCodeListener(callbackContext)); } catch (IOException e) { e.printStackTrace(); Log.d("Failed to get QR Code", e.getMessage()); - promise.reject("Failed to get QR Code", e.getMessage()); } - + + //try { + // qrCode.getQRCodeAsData(this.activity, branchUniversalObject, linkProperties, new GetBranchQRCodeListener(callbackContext)) { + // @Override + // public void onSuccess(byte[] qrCodeData) { + // String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); + // promise.resolve(qrCodeString); + // } + + // @Override + // public void onFailure(Exception e) { + // Log.d("Failed to get QR Code", e.getMessage()); + // promise.reject("Failed to get QR Code", e.getMessage()); + // } + // }); + // } catch (IOException e) { + // e.printStackTrace(); + // Log.d("Failed to get QR Code", e.getMessage()); + // promise.reject("Failed to get QR Code", e.getMessage()); + // } + //branchUniversalWrapper.branchUniversalObj.generateShortUrl(this.activity, linkProperties, new GenerateShortUrlListener(callbackContext)); } @@ -1060,6 +1074,38 @@ public void onLinkCreate(String url, BranchError error) { } + protected class GetBranchQRCodeListener implements BranchQRCode.BranchQRCodeDataHandler { + private CallbackContext _callbackContext; + + // Constructor that takes in a required callbackContext object + public GetBranchQRCodeListener(CallbackContext callbackContext) { + + this._callbackContext = callbackContext; + + } + + @Override + public void onSuccess(byte[] qrCodeData) { + + String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); + + String response = qrCodeString; + + Log.d(LCAT, response); + this._callbackContext.success(response); + } + + @Override + public void onFailure(Exception e) { + + String errorMessage = String.valueOf(e); + + Log.d(LCAT, errorMessage); + this._callbackContext.error(errorMessage); + } + + } + protected class ShowShareSheetListener implements Branch.BranchLinkShareListener { private CallbackContext _onShareLinkDialogLaunched; @@ -1239,6 +1285,8 @@ public void run() { lastAttributedTouchData(this.callbackContext); } else if (this.action.equals(("generateShortUrl"))) { generateShortUrl(this.args.getInt(0), this.args.getJSONObject(1), this.args.getJSONObject(2), this.callbackContext); + } else if (this.action.equals(("getBranchQRCode"))) { + getBranchQRCode(this.args.getJSONObject(0), this.args.getInt(1), this.args.getJSONObject(2), this.args.getJSONObject(3), this.callbackContext); } else if (this.action.equals("registerView")) { registerView(this.args.getInt(0), this.callbackContext); } else if (this.action.equals("showShareSheet")) { From 3468762503c38430c6e3800e2de201fd2cf54621 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Tue, 26 Jul 2022 11:54:35 -0700 Subject: [PATCH 22/37] Updated android --- src/android/io/branch/BranchSDK.java | 97 +++++++++++----------------- src/ios/BranchSDK.m | 6 +- 2 files changed, 38 insertions(+), 65 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 72589f06..563946f3 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -228,6 +228,10 @@ 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 mismatched. 4 is required but %d is given", args.length())); + return false; + } cordova.getActivity().runOnUiThread(r); return true; } @@ -530,38 +534,43 @@ private void getBranchQRCode(JSONObject qrCodeSettings, int instanceIdx, JSONObj BranchUniversalObjectWrapper branchUniversalWrapper = (BranchUniversalObjectWrapper) this.branchObjectWrappers.get(instanceIdx); BranchUniversalObject buo = branchUniversalWrapper.branchUniversalObj; - BranchQRCode qrCode = new BranchQRCode(); - //setCodeColor, setWidth, etc. + 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 { - qrCode.getQRCodeAsData(this.activity, buo, linkProperties, new GetBranchQRCodeListener(callbackContext)); + 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("Failed to get QR Code", e.getMessage()); + Log.d(LCAT, e.getMessage()); + callbackContext.error(e.getMessage()); } - - //try { - // qrCode.getQRCodeAsData(this.activity, branchUniversalObject, linkProperties, new GetBranchQRCodeListener(callbackContext)) { - // @Override - // public void onSuccess(byte[] qrCodeData) { - // String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); - // promise.resolve(qrCodeString); - // } - - // @Override - // public void onFailure(Exception e) { - // Log.d("Failed to get QR Code", e.getMessage()); - // promise.reject("Failed to get QR Code", e.getMessage()); - // } - // }); - // } catch (IOException e) { - // e.printStackTrace(); - // Log.d("Failed to get QR Code", e.getMessage()); - // promise.reject("Failed to get QR Code", e.getMessage()); - // } - - //branchUniversalWrapper.branchUniversalObj.generateShortUrl(this.activity, linkProperties, new GenerateShortUrlListener(callbackContext)); - } /** @@ -1073,39 +1082,7 @@ public void onLinkCreate(String url, BranchError error) { } } - - protected class GetBranchQRCodeListener implements BranchQRCode.BranchQRCodeDataHandler { - private CallbackContext _callbackContext; - - // Constructor that takes in a required callbackContext object - public GetBranchQRCodeListener(CallbackContext callbackContext) { - - this._callbackContext = callbackContext; - - } - - @Override - public void onSuccess(byte[] qrCodeData) { - - String qrCodeString = Base64.encodeToString(qrCodeData, Base64.DEFAULT); - - String response = qrCodeString; - - Log.d(LCAT, response); - this._callbackContext.success(response); - } - - @Override - public void onFailure(Exception e) { - - String errorMessage = String.valueOf(e); - - Log.d(LCAT, errorMessage); - this._callbackContext.error(errorMessage); - } - - } - + protected class ShowShareSheetListener implements Branch.BranchLinkShareListener { private CallbackContext _onShareLinkDialogLaunched; diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index f5d4e5e7..5b971816 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -653,9 +653,8 @@ - (void)getBranchQRCode:(CDVInvokedUrlCommand*)command int branchUniversalObjectId = [[command.arguments objectAtIndex:1] intValue]; NSMutableDictionary *branchUniversalObjDict = [self.branchUniversalObjArray objectAtIndex:branchUniversalObjectId]; BranchUniversalObject *branchUniversalObj = [branchUniversalObjDict objectForKey:@"branchUniversalObj"]; - //BranchUniversalObject *branchUniversalObj = [BranchUniversalObject new];//[[BranchUniversalObject alloc] initWithMap:universalObjectProperties]; - BranchLinkProperties *linkProperties = [BranchLinkProperties new];//[self createLinkProperties:linkPropertiesMap withControlParams:controlParamsMap]; + BranchLinkProperties *linkProperties = [BranchLinkProperties new]; NSDictionary *arg1 = [command.arguments objectAtIndex:2]; NSDictionary *arg2 = [command.arguments objectAtIndex:3]; @@ -689,7 +688,6 @@ - (void)getBranchQRCode:(CDVInvokedUrlCommand*)command } } - NSMutableDictionary *qrCodeSettingsMap = [command.arguments objectAtIndex:0]; BranchQRCode *qrCode = [BranchQRCode new]; @@ -722,10 +720,8 @@ - (void)getBranchQRCode:(CDVInvokedUrlCommand*)command if (!error) { NSString* imageString = [qrCodeData base64EncodedStringWithOptions:nil]; - NSLog(@"Success"); pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:imageString]; } else { - NSLog(@"Error"); pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; } From 97792966b124627558e3bb700c4740b6f626b6ad Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Thu, 28 Jul 2022 11:04:07 -0700 Subject: [PATCH 23/37] Fixes based on feedback --- .gitignore | 1 + ...onegap-branch-deep-linking-attribution.iml | 11 ---------- src/android/io/branch/BranchSDK.java | 20 ++++++++++++++----- 3 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 cordova-ionic-phonegap-branch-deep-linking-attribution.iml 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/cordova-ionic-phonegap-branch-deep-linking-attribution.iml b/cordova-ionic-phonegap-branch-deep-linking-attribution.iml deleted file mode 100644 index 93f7e2e2..00000000 --- a/cordova-ionic-phonegap-branch-deep-linking-attribution.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 563946f3..fccb6791 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -535,11 +535,21 @@ private void getBranchQRCode(JSONObject qrCodeSettings, int instanceIdx, JSONObj 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("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 ) { From 10b5cdaaf23f33e6b02b24d2a3a9f79658ecec63 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Thu, 4 Aug 2022 15:34:02 -0700 Subject: [PATCH 24/37] Updated parameter mismatch comment --- src/android/io/branch/BranchSDK.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index fccb6791..cb839b8e 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -141,14 +141,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())); + 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); @@ -164,7 +164,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo 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); @@ -180,21 +180,21 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo } 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); @@ -229,7 +229,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo } else if (action.equals("getBranchQRCode")) { if (args.length() != 4) { - callbackContext.error(String.format("Parameter mismatched. 4 is required but %d is given", args.length())); + callbackContext.error(String.format("Parameter count mismatch")); return false; } cordova.getActivity().runOnUiThread(r); From 4e4b3427dca76c9513b6b85db679aa9b69b86d42 Mon Sep 17 00:00:00 2001 From: nsingh-branch Date: Mon, 8 Aug 2022 16:29:09 -0700 Subject: [PATCH 25/37] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f4ccda1..25393be8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +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 From 6998860aa7179f76f0a140c3edacec8d24b95672 Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Thu, 8 Sep 2022 02:48:09 -0700 Subject: [PATCH 26/37] new issue report form --- .github/ISSUE_TEMPLATE/bug-report.yml | 74 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 9 +++ .github/ISSUE_TEMPLATE/feature-request.yml | 14 ++++ 3 files changed, 97 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..6b9fd969 --- /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, stacktraces, 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 From 875f2b6c0a13a3385045f91b43acc5ad993a4f76 Mon Sep 17 00:00:00 2001 From: gdeluna-branch <94577415+gdeluna-branch@users.noreply.github.com> Date: Thu, 8 Sep 2022 03:46:33 -0700 Subject: [PATCH 27/37] Update bug-report.yml --- .github/ISSUE_TEMPLATE/bug-report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 6b9fd969..39c0d1e5 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -12,7 +12,7 @@ body: required: true - attributes: - description: "Please provide as much step-by-step detail as possible including logs, stacktraces, and uncaught exceptions." + description: "Please provide as much step-by-step detail as possible including logs, stack traces, and uncaught exceptions." label: "Steps to reproduce" value: | 1. From 742582f9e19c73ba807510f7232f8d1de036caad Mon Sep 17 00:00:00 2001 From: gdeluna-branch Date: Thu, 8 Sep 2022 14:24:42 -0700 Subject: [PATCH 28/37] Create SECURITY.md --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md 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. From b35329dadf10f7b1998d69af8a037c10c571bc5a Mon Sep 17 00:00:00 2001 From: nsingh-branch <88689850+nsingh-branch@users.noreply.github.com> Date: Tue, 13 Dec 2022 11:14:29 -0800 Subject: [PATCH 29/37] Added PR template --- .github/PULL_REQUEST_TEMPLATE.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md 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 +<!-- Simple summary of what was changed. --> + +## Motivation +<!-- Why are you making this change? If it's for fixing a bug, if possible, please include a code snippet or example project that demonstrates the issue. --> + +## Type Of Change +<!-- Please delete options that are not relevant --> +- [ ] 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 +<!-- Testing instructions, example code snippets, etc --> + + +<!-- Checklist --> +<!-- My code follows the style guidelines of this project --> +<!-- I have performed a self-review of my code --> +<!-- I have commented my code, particularly in hard-to-understand areas --> +<!-- I have made corresponding changes to the documentation --> +<!-- I have added tests that prove my fix is effective or that my feature works --> +<!-- New and existing unit tests pass locally with my changes --> + +cc @BranchMetrics/saas-sdk-devs for visibility. From ca4d622d310f62cfc710196ea5637bc92b9a8734 Mon Sep 17 00:00:00 2001 From: gdeluna-branch <gabriel.deluna@branch.io> Date: Wed, 14 Dec 2022 17:35:26 -0800 Subject: [PATCH 30/37] fix enablelogging command string --- src/android/io/branch/BranchSDK.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index cb839b8e..aaaa7ae9 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -119,7 +119,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo Runnable r = new RunnableThread(action, args, callbackContext); - if (action.equals("setLogging")) { + if (action.equals("enableLogging")) { cordova.getActivity().runOnUiThread(r); return true; } else if (action.equals("setCookieBasedMatching")) { @@ -607,7 +607,7 @@ private void setCookieBasedMatching(String linkDomain, CallbackContext callbackC * @param isEnable A {@link Boolean} value to enable/disable logging * @param callbackContext A callback to execute at the end of this method */ - private void setLogging(boolean isEnable, CallbackContext callbackContext) { + private void enableLogging(boolean isEnable, CallbackContext callbackContext) { this.activity = this.cordova.getActivity(); if (isEnable == true) { Branch.enableLogging(); @@ -1233,8 +1233,8 @@ public void run() { try { Log.d(LCAT, "Runnable: " + this.action); - if (this.action.equals("setLogging")) { - setLogging(this.args.getBoolean(0), this.callbackContext); + if (this.action.equals("enableLogging")) { + enableLogging(this.args.getBoolean(0), this.callbackContext); } else if (this.action.equals("setCookieBasedMatching")) { setCookieBasedMatching(this.args.getString(0), this.callbackContext); } else if (this.action.equals("disableTracking")) { From 32532b0ebc4b2ea11c6986c9b5f4b722e14bd83a Mon Sep 17 00:00:00 2001 From: gdeluna-branch <gabriel.deluna@branch.io> Date: Wed, 14 Dec 2022 18:03:02 -0800 Subject: [PATCH 31/37] update sdks --- package.json | 2 +- plugin.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 245e90de..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": "5.2.0", + "version": "5.2.1", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.xml b/plugin.xml index 5d746a60..0fb30993 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="branch-cordova-sdk" - version="5.1.0"> + version="5.2.1"> <!-- Description --> <name>branch-cordova-sdk</name> @@ -63,7 +63,7 @@ SOFTWARE. <!-- Manifest configuration is done via a js script. We should move it to this config in the future. --> <source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" /> - <framework src="io.branch.sdk.android:library:5.2.0"/> + <framework src="io.branch.sdk.android:library:5.2.7"/> </platform> <!-- iOS --> @@ -87,7 +87,7 @@ SOFTWARE. <source url="https://cdn.cocoapods.org/"/> </config> <pods> - <pod name="Branch" spec="~> 1.43.1" /> + <pod name="Branch" spec="~> 1.45.1" /> </pods> </podspec> </platform> From df1cba7d57d9611021cf2b93a6d38754cae6ef88 Mon Sep 17 00:00:00 2001 From: gdeluna-branch <gabriel.deluna@branch.io> Date: Wed, 14 Dec 2022 18:06:37 -0800 Subject: [PATCH 32/37] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25393be8..09de1168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +5.2.1 December 14, 2022 +* Fix Javascript method setLogging to enable logging in the native layer. +* Update Android SDK to 5.2.7 +* Update iOS SDK to 1.45.1 + 5.2.0 August 8th, 2022 * Update iOS SDK to 1.43.1 * Update Android SDK to 5.2.0 From 1d7f99a4d29c72a08dc83f849c0591505f7798d8 Mon Sep 17 00:00:00 2001 From: gdeluna-branch <gabriel.deluna@branch.io> Date: Thu, 15 Dec 2022 19:56:33 -0800 Subject: [PATCH 33/37] Create README.md --- .github/workflows/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/README.md diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 00000000..e69de29b From 63c2762efaf5217e095f740fc2d2e6dfefd0cdba Mon Sep 17 00:00:00 2001 From: maheshbudhe <92872660+maheshbudhe@users.noreply.github.com> Date: Wed, 21 Dec 2022 18:55:11 +0530 Subject: [PATCH 34/37] Create automation-trigger-test.yml Cordova CI/CD Automation trigger file created --- .github/workflows/automation-trigger-test.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/automation-trigger-test.yml 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' + }) From 4251e84634aee521f065da5b3b7a428893ba9e94 Mon Sep 17 00:00:00 2001 From: gdeluna-branch <gabriel.deluna@branch.io> Date: Wed, 4 Jan 2023 11:08:58 -0800 Subject: [PATCH 35/37] bump ios sdk to 1.45.2 --- CHANGELOG.md | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09de1168..7ed894c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ 5.2.1 December 14, 2022 * Fix Javascript method setLogging to enable logging in the native layer. * Update Android SDK to 5.2.7 -* Update iOS SDK to 1.45.1 +* Update iOS SDK to 1.45.2 5.2.0 August 8th, 2022 * Update iOS SDK to 1.43.1 diff --git a/plugin.xml b/plugin.xml index 0fb30993..0ac900f8 100644 --- a/plugin.xml +++ b/plugin.xml @@ -87,7 +87,7 @@ SOFTWARE. <source url="https://cdn.cocoapods.org/"/> </config> <pods> - <pod name="Branch" spec="~> 1.45.1" /> + <pod name="Branch" spec="~> 1.45.2" /> </pods> </podspec> </platform> From c14bd68c496a55d1cf6a380456f98ee3c5f07283 Mon Sep 17 00:00:00 2001 From: gdeluna-branch <gabriel.deluna@branch.io> Date: Wed, 4 Jan 2023 11:09:27 -0800 Subject: [PATCH 36/37] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ed894c6..08b94cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -5.2.1 December 14, 2022 +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 From 70de5d289cc306a50686156ae8419160af4c176e Mon Sep 17 00:00:00 2001 From: nsingh-branch <88689850+nsingh-branch@users.noreply.github.com> Date: Mon, 12 Jun 2023 17:25:47 -0700 Subject: [PATCH 37/37] Added Stale GHA --- .github/workflows/stale.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/stale.yml 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'