Skip to content

Commit a043278

Browse files
authored
Merge pull request #655 from adrianyg7/send-branch-event
fix(android): sendBranchEvent single parameter
2 parents 8bf7398 + dec5954 commit a043278

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/android/io/branch/BranchSDK.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,20 @@ private void sendCommerceEvent(JSONObject action, JSONObject metaData, CallbackC
781781

782782
}
783783

784+
public void sendBranchEvent(String eventName, CallbackContext callbackContext) throws JSONException {
785+
786+
BranchEvent event;
787+
try {
788+
BRANCH_STANDARD_EVENT standardEvent = BRANCH_STANDARD_EVENT.valueOf(eventName);
789+
event = new BranchEvent(standardEvent);
790+
} catch(IllegalArgumentException e) {
791+
event = new BranchEvent(eventName);
792+
}
793+
794+
event.logEvent(this.activity);
795+
//callbackContext.success();
796+
}
797+
784798
public void sendBranchEvent(String eventName, JSONObject metaData, CallbackContext callbackContext) throws JSONException {
785799

786800
BranchEvent event;
@@ -1422,7 +1436,11 @@ public void run() {
14221436
} else if (this.action.equals("sendCommerceEvent")) {
14231437
sendCommerceEvent(this.args.getJSONObject(0), this.args.getJSONObject(1), this.callbackContext);
14241438
} else if (this.action.equals("sendBranchEvent")) {
1425-
sendBranchEvent(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext);
1439+
if (this.args.length() == 2) {
1440+
sendBranchEvent(this.args.getString(0), this.args.getJSONObject(1), this.callbackContext);
1441+
} else if (this.args.length() == 1) {
1442+
sendBranchEvent(this.args.getString(0), this.callbackContext);
1443+
}
14261444
} else if (this.action.equals("getFirstReferringParams")) {
14271445
getFirstReferringParams(this.callbackContext);
14281446
} else if (this.action.equals("getLatestReferringParams")) {

0 commit comments

Comments
 (0)