Skip to content

Commit

Permalink
Merge pull request #86 from pragunvohra/setDebugPromises
Browse files Browse the repository at this point in the history
resolve setDebug promise on Android & ios with passed-in value
  • Loading branch information
aaustin committed Mar 27, 2016
2 parents 6fe171a + c6290ae commit 47024d4
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 @@ -103,7 +103,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 @@ -652,8 +652,9 @@ private void generateShortUrl(int instanceIdx, JSONObject options, JSONObject co
* <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 @@ -666,6 +667,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 47024d4

Please sign in to comment.