Skip to content

Commit

Permalink
Merge pull request #161 from BranchMetrics/fix-android-nondeeplinkhan…
Browse files Browse the repository at this point in the history
…dler

Fix Android NonBranchLinkHandler
  • Loading branch information
aaustin authored Jun 29, 2016
2 parents aca745d + 548cc65 commit a6bc7e9
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,34 +701,39 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {

String out;

if (error == null) {
if (error == null && referringParams != null) {

// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found.
if (referringParams != null) {

out = String.format("DeepLinkHandler(%s)", referringParams.toString());

webView.sendJavascript(out);

try {
if (referringParams.has("+clicked_branch_link") && referringParams.getBoolean("+clicked_branch_link")) {
out = String.format("DeepLinkHandler(%s)", referringParams.toString());
webView.sendJavascript(out);
} else if (deepLinkUrl != null) {
JSONObject message = new JSONObject();

message.put("error", "Not a Branch link!");
message.put("url", deepLinkUrl);
deepLinkUrl = null;

out = String.format("NonBranchLinkHandler(\"%s\")", message.toString());
webView.sendJavascript(out);
}
} catch (JSONException e) {
e.printStackTrace();
}

if (this._callbackContext != null) {
this._callbackContext.success(referringParams);
}

} else if (deepLinkUrl != null) {
} else {
JSONObject message = new JSONObject();
try {
message.put("error", "Not a Branch link!");
message.put("url", deepLinkUrl);
deepLinkUrl = null;
message.put("error", error.getMessage());
} catch (JSONException e) {
e.printStackTrace();
}

out = String.format("NonBranchLinkHandler(\"%s\")", message.toString());
webView.sendJavascript(out);

if (this._callbackContext != null) {
this._callbackContext.error(message);
Expand Down

0 comments on commit a6bc7e9

Please sign in to comment.