Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Android NonBranchLinkHandler #161

Merged
merged 1 commit into from
Jun 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey malua - Haven't had any time to review yet unfortunately but I will today or tomorrow.

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