Skip to content

Commit

Permalink
Merge pull request #111 from BranchMetrics/feat/deeplink-error-handler
Browse files Browse the repository at this point in the history
[FEAT] On error handler for handling deep link urls.
  • Loading branch information
aaustin committed Apr 19, 2016
2 parents 79e2516 + 5b0b368 commit 9e709ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -773,16 +773,16 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {

Log.d(LCAT, "SessionListener onInitFinished()");

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

webView.sendJavascript(out);
String out = "";

if (this._callbackContext == null) {
return;
}

if (error == null) {

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

// 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) {
Expand All @@ -798,11 +798,15 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {
} else {
String errorMessage = error.getMessage();

out = String.format("NonBranchLinkHandler(%s)", error.toString());

Log.d(LCAT, errorMessage);

this._callbackContext.error(errorMessage);
}

webView.sendJavascript(out);

}

}
Expand Down
7 changes: 7 additions & 0 deletions testbed/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ function NonBranchLinkHandler(data)
}
}

function NonBranchLinkHandler(data)
{
if (data) {
alert('Non-branch link found: ' + JSON.stringify(data));
}
}

function SetDebug(isEnabled)
{
console.log('Trigger SetDebug()');
Expand Down

0 comments on commit 9e709ca

Please sign in to comment.