Skip to content

Commit

Permalink
resolve setDebug promise on Android & ios with passed-in value
Browse files Browse the repository at this point in the history
Worth noting that it looks like doing the following:

initSession()
setDebug(true)
setDebug(false)

will currently leave the debug state as true since false is pretty much
a no-op. This commit at least fixes (on iOS) so that if you do
initSession() then setDebug(false), it doesn’t set debug mode to on.

Both platforms now return a proper bool value of true/false.
  • Loading branch information
pragunvohra committed Mar 25, 2016
1 parent 7ea01ee commit c6290ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo

if (action.equals("setDebug")) {
if (args.length() == 1) {
this.setDebug(args.getBoolean(0));
this.setDebug(args.getBoolean(0), callbackContext);
}
return true;
} else if (action.equals("initSession")) {
Expand Down Expand Up @@ -577,8 +577,9 @@ private void generateShortUrl(JSONObject options, JSONObject controlParams, Call
* <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)
private void setDebug(boolean isEnable, CallbackContext callbackContext)
{

Log.d(LCAT, "start setDebug()");
Expand All @@ -591,6 +592,7 @@ private void setDebug(boolean isEnable)
debugInstance.setDebug();
}

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

/**
Expand Down
10 changes: 9 additions & 1 deletion src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ - (void)initSession:(CDVInvokedUrlCommand*)command
- (void)setDebug:(CDVInvokedUrlCommand*)command
{
NSLog(@"start setDebug");
[[Branch getInstance] setDebug];
CDVPluginResult* pluginResult;
bool enableDebug = [[command.arguments objectAtIndex:0] boolValue] == YES;
if (enableDebug) {
[[Branch getInstance] setDebug];
}

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

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

- (void)getAutoInstance:(CDVInvokedUrlCommand*)command
Expand Down

0 comments on commit c6290ae

Please sign in to comment.