Skip to content

Commit

Permalink
fix: added android chrome tabs for better matching
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanneff committed Jul 11, 2017
1 parent a66caae commit 92bfefe
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,10 @@
// for development and debugging only
Branch.setDebug(true)

// sync with Mixpanel if installed
// for better Android matching
Branch.setCookieBasedMatching('cordova.app.link')

// to sync with Mixpanel if plugin is installed
Branch.setMixpanelToken('your_mixpanel_token')

// Branch initialization
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// branch chrome tabs for better matching
compile 'com.android.support:customtabs:23.3.0'
21 changes: 21 additions & 0 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,27 @@ private void generateShortUrl(int instanceIdx, JSONObject options, JSONObject co

}

/**
* <p>Sets the cookie based matching for all incoming requests.</p>
* <p>If you want cookie based matching, call this <b>before</b> initUserSession</p>
*
* @param linkDomain A {@link String} value to of the link domain for cookie based matching.
* @param callbackContext A callback to execute at the end of this method
*/
private void setCookieBasedMatching(String linkDomain, CallbackContext callbackContext)
{

this.activity = this.cordova.getActivity();

Branch instance = Branch.getAutoInstance(this.activity.getApplicationContext());

if (linkDomain != null) {
instance.enableCookieBasedMatching(linkDomain);
}

callbackContext.success("Success");
}

/**
* <p>Sets the library to function in debug mode, enabling logging of all requests.</p>
* <p>If you want to flag debug, call this <b>before</b> initUserSession</p>
Expand Down
6 changes: 6 additions & 0 deletions src/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ Branch.prototype.setDebug = function (isEnabled) {
return execute('setDebug', [isEnabled])
}

Branch.prototype.setCookieBasedMatching = function (linkDomain) {
if (linkDomain && deviceVendor.indexOf('Apple') < 0) {
return execute('setCookieBasedMatching', [linkDomain])
}
}

Branch.prototype.getFirstReferringParams = function () {
return execute('getFirstReferringParams')
}
Expand Down
3 changes: 3 additions & 0 deletions testbed/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ function BranchInit (isDebug) {
// for development and debugging only
Branch.setDebug(isDebug)

// for better Android matching
Branch.setCookieBasedMatching('cordova.app.link')

// sync with Mixpanel if installed
Branch.setMixpanelToken('your_mixpanel_token')

Expand Down

0 comments on commit 92bfefe

Please sign in to comment.