From 8b9e83fd1e2a222923055e802342dbd97bab6420 Mon Sep 17 00:00:00 2001 From: Renemari Padillo Date: Mon, 18 Apr 2016 18:04:43 +0800 Subject: [PATCH 1/2] [FEAT] On error handler for handling deep link urls. --- src/android/io/branch/BranchSDK.java | 12 +++++++++--- testbed/www/js/index.js | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index c86a6e8f..36ed06a9 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -54,6 +54,8 @@ public void onNewIntent(Intent intent) this.activity = this.cordova.getActivity(); this.activity.setIntent(intent); + Log.d(LCAT, String.format("%s", intent.getDataString())); + if (this.activity != null) { this.initSession(null); } @@ -773,9 +775,7 @@ 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; @@ -783,6 +783,8 @@ public void onInitFinished(JSONObject referringParams, BranchError error) { 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) { @@ -798,11 +800,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); + } } diff --git a/testbed/www/js/index.js b/testbed/www/js/index.js index ab21e567..ee3feb4f 100644 --- a/testbed/www/js/index.js +++ b/testbed/www/js/index.js @@ -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()'); From 5b0b368951765dc87516e8e360b73a23481a7b06 Mon Sep 17 00:00:00 2001 From: Renemari Padillo Date: Tue, 19 Apr 2016 13:06:41 +0800 Subject: [PATCH 2/2] [CHORE] Removed unnecessary log. --- src/android/io/branch/BranchSDK.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 36ed06a9..a2eb5405 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -54,8 +54,6 @@ public void onNewIntent(Intent intent) this.activity = this.cordova.getActivity(); this.activity.setIntent(intent); - Log.d(LCAT, String.format("%s", intent.getDataString())); - if (this.activity != null) { this.initSession(null); }