Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Renemari Padillo committed Aug 9, 2016
2 parents bacb28a + 60c0b60 commit 1471574
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 112 deletions.
17 changes: 0 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ Branch.getFirstReferringParams().then(function (res) {
```

1. Branch Session
+ [setDebug](#setDebug)
+ [initSession](#initSession)
+ [setMixpanelToken](#setMixpanelToken)
+ [getLatestReferringParams](#getLatestReferringParams)
Expand All @@ -186,25 +185,9 @@ Branch.getFirstReferringParams().then(function (res) {
4. FAQ
+ [Android Build FAQ](#android-build-faq)


### <a id="setDebug"></a>setDebug(isEnable)

Setting the SDK debug flag will generate a new device ID each time the app is installed instead of possibly using the same device id.
This is useful when testing.

**Parameters**

**options**: `boolean` - Boolean flag if debug mode should be enabled or not.

##### Usage
```js
Branch.setDebug(true);
```

### <a id="initSession"></a>initSession()

Initializes the branch instance.
**Note:** `setDebug()` should be called first before calling this method.

##### Usage
The `initSession()` method automatically also sets an internal deep link hander whose data can be accesed by implementing the **required** `DeepLinkHandler()` method. To implement, first call the method `initSession`:
Expand Down
70 changes: 16 additions & 54 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,32 @@ static class BranchLinkProperties extends io.branch.referral.util.LinkProperties
*/
public BranchSDK()
{

this.activity = null;
this.instance = null;
this.branchObjectWrappers = new ArrayList<BranchUniversalObjectWrapper>();
}

/**
* Called when the activity receives a new intent.
*/
public void onNewIntent(Intent intent)
{
this.activity = this.cordova.getActivity();
this.activity.setIntent(intent);

if (this.activity != null) {
this.initSession(null);
}
}

/**
* Called when the activity will start interacting with the user.
*
* @param multitasking A {@link boolean} flag indicating if multitasking is turned on for app
* Called after plugin construction and fields have been initialized.
*/
@Override
public void onResume(boolean multitasking) {
protected void pluginInitialize() {

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

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

}

/**
* Called when the activity is no longer visible to the user.
* Called when the activity receives a new intent.
*/
@Override
public void onStop()
{
public void onNewIntent(Intent intent)
{

if (this.instance != null) {
this.instance.closeSession();
}
this.activity.setIntent(intent);

}

Expand All @@ -98,12 +86,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo

Runnable r = new RunnableThread(action, args, callbackContext);

if (action.equals("setDebug")) {
if (args.length() == 1) {
cordova.getThreadPool().execute(r);
}
return true;
} else if (action.equals("initSession")) {
if (action.equals("initSession")) {
cordova.getThreadPool().execute(r);
return true;
} else if (action.equals("setMixpanelToken")) {
Expand Down Expand Up @@ -224,16 +207,18 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
*/
private void initSession(CallbackContext callbackContext)
{

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

Uri data = activity.getIntent().getData();

if (data != null && data.isHierarchical()) {
this.deepLinkUrl = data.toString();
}

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

this.instance.initSession(new SessionListener(callbackContext), data, activity);

}

/**
Expand Down Expand Up @@ -554,27 +539,6 @@ private void generateShortUrl(int instanceIdx, JSONObject options, JSONObject co

}

/**
* <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>
*
* @param isEnable A {@link Boolean} value to enable/disable debugging mode for the app.
* @param callbackContext A callback to execute at the end of this method
*/
private void setDebug(boolean isEnable, CallbackContext callbackContext)
{

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

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

if (isEnable) {
debugInstance.setDebug();
}

callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, /* send boolean: false as the data */ isEnable));
}

/**
* <p>Identifies the current user to the Branch API by supplying a unique
* identifier as a {@link String} value.</p>
Expand Down Expand Up @@ -1157,9 +1121,7 @@ public RunnableThread(String action, JSONArray args, CallbackContext callbackCon

public void run() {
try {
if (this.action.equals("setDebug")) {
setDebug(this.args.getBoolean(0), this.callbackContext);
} else if (this.action.equals("initSession")) {
if (this.action.equals("initSession")) {
initSession(this.callbackContext);
} else if (this.action.equals("setMixpanelToken")) {
setMixpanelToken(this.args.getString(0), this.callbackContext);
Expand Down
1 change: 0 additions & 1 deletion src/ios/BranchSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
// BranchSDK Basic Methods
- (void)initSession:(CDVInvokedUrlCommand*)command;
- (void)setMixpanelToken:(CDVInvokedUrlCommand*)command;
- (void)setDebug:(CDVInvokedUrlCommand*)command;
- (void)getAutoInstance:(CDVInvokedUrlCommand*)command;
- (void)getLatestReferringParams:(CDVInvokedUrlCommand*)command;
- (void)getFirstReferringParams:(CDVInvokedUrlCommand*)command;
Expand Down
12 changes: 0 additions & 12 deletions src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,6 @@ - (void)setMixpanelToken:(CDVInvokedUrlCommand*)command

}

- (void)setDebug:(CDVInvokedUrlCommand*)command
{
bool enableDebug = [[command.arguments objectAtIndex:0] boolValue] == YES;
if (enableDebug) {
[[Branch getInstance] setDebug];
}

CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:enableDebug];

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)getAutoInstance:(CDVInvokedUrlCommand*)command
{
[self initSession:nil];
Expand Down
10 changes: 0 additions & 10 deletions testbed/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var app = {
document.getElementsByTagName("html")[0].className = 'android';
}

SetDebug(true);
InitSession();

}
Expand All @@ -69,15 +68,6 @@ function NonBranchLinkHandler(data)
}
}

function SetDebug(isEnabled)
{
console.log('Trigger SetDebug()');

Branch.setDebug(isEnabled);

alert('Debug mode enabled');
}

function InitSession()
{
console.log('Trigger InitSession()');
Expand Down
18 changes: 0 additions & 18 deletions www/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,6 @@ Branch.prototype.setMixpanelToken = function (token) {

};

/**
* Set debug mode.
* NOTE: This must be called before initSession
*
* @param (Boolean) isEnabled. Default = false
*
* @return (Promise)
*/
Branch.prototype.setDebug = function (isEnabled) {

isEnabled = (typeof isEnabled !== 'boolean') ? false : isEnabled;

this.debugMode = isEnabled;

return execute('setDebug', [isEnabled]);

};

/**
* Retrieves the install session parameters.
*
Expand Down

0 comments on commit 1471574

Please sign in to comment.