diff --git a/package.json b/package.json index 94f0e040..5c017f46 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "branch-cordova-sdk", "description": "Branch Metrics Cordova SDK", "main": "src/branch.js", - "version": "2.6.14", + "version": "2.6.15", "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", diff --git a/plugin.template.xml b/plugin.template.xml index e9698417..8c5e394e 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="2.6.15"> diff --git a/plugin.xml b/plugin.xml index a7ebed97..dcf76f19 100644 --- a/plugin.xml +++ b/plugin.xml @@ -24,7 +24,7 @@ SOFTWARE. + version="2.6.15"> diff --git a/src/android/io/branch/BranchSDK.java b/src/android/io/branch/BranchSDK.java index 574e23dc..0eaa27d6 100644 --- a/src/android/io/branch/BranchSDK.java +++ b/src/android/io/branch/BranchSDK.java @@ -3,6 +3,9 @@ import android.app.Activity; import android.content.Intent; import android.util.Log; +import android.annotation.TargetApi; +import android.net.Uri; +import android.os.Build; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; @@ -15,8 +18,6 @@ import java.util.ArrayList; import java.util.Iterator; -import android.net.Uri; - import io.branch.indexing.BranchUniversalObject; import io.branch.referral.Branch; import io.branch.referral.BranchError; @@ -74,6 +75,23 @@ public void onNewIntent(Intent intent) { } + /** + * Handle depreciated call to sendJavaScript for more recent method + */ + @TargetApi(Build.VERSION_CODES.KITKAT) + private void sendJavascript(final String javascript) { + webView.getView().post(new Runnable() { + @Override + public void run() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + webView.sendJavascript(javascript); + } else { + webView.loadUrl("javascript:" + javascript); + } + } + }); + } + /** *

* cordova.exec() method reference. @@ -808,7 +826,7 @@ public void onInitFinished(JSONObject referringParams, BranchError error) { if (error == null && referringParams != null) { out = String.format("DeepLinkHandler(%s)", referringParams.toString()); - webView.sendJavascript(out); + sendJavascript(out); if (this._callbackContext != null) { this._callbackContext.success(referringParams); diff --git a/src/branch.js b/src/branch.js index 1f6684f3..ee11e55a 100644 --- a/src/branch.js +++ b/src/branch.js @@ -35,8 +35,8 @@ Branch.prototype.disableGlobalListenersWarnings = function () { disableGlobalListenersWarnings = true } -var previousLinkTimestamp = null var runOnce = true +var previousLinkTimestamp = null Branch.prototype.initSession = function (deepLinkDataListener) { // handle double init from onResume on iOS if (!runOnce) return new Promise(function (resolve, reject) {}) @@ -44,13 +44,13 @@ Branch.prototype.initSession = function (deepLinkDataListener) { // private method to filter out +clicked_branch_link = false in deep link callback var deepLinkDataParser = function (deepLinkData) { + var timestamp = '+click_timestamp' var isBranchLink = '+clicked_branch_link' var isNonBranchLink = '+non_branch_link' - var timestamp = '+click_timestamp' var isBranchLinkClick = deepLinkData.hasOwnProperty(isBranchLink) && deepLinkData[isBranchLink] === true var isNonBranchLinkClick = deepLinkData.hasOwnProperty(isNonBranchLink) - var currentLinkTimestamp = deepLinkData.hasOwnProperty(timestamp) ? deepLinkData[timestamp] : null + var currentLinkTimestamp = deepLinkData.hasOwnProperty(timestamp) ? deepLinkData[timestamp] : Date.now() // is +clicked_branch_link' = true || +non_branch_link && !previousLinkTimestamp if ((isBranchLinkClick || isNonBranchLinkClick) && currentLinkTimestamp !== previousLinkTimestamp) { diff --git a/testbed/www/css/index.css b/testbed/www/css/index.css index 5f4564c7..639e96e0 100644 --- a/testbed/www/css/index.css +++ b/testbed/www/css/index.css @@ -4,8 +4,32 @@ background-color: #FFFFFF; } body { - padding: 0.8em 0em 0.2em 0em; + display: flex; + flex-direction: column; + padding: 1em 0em 0.5em 0em; max-width: 40em; + margin: 0 auto; +} +fieldset { + border-color: #303030; + margin: 0.5em 1em; + padding: 0.75em; +} +fieldset > *:not(:first-child) { + margin-bottom: 0.5em; +} +fieldset > *:last-child { + margin-bottom: 0; +} +section { + display: flex; + flex-direction: row; +} +section > button:nth-child(even) { + margin-left: 0.5em; +} +section > button:nth-child(odd) { + margin-right: 0.5em; } button, input { padding: 0.5em; @@ -14,20 +38,4 @@ button, input { } button { background-color: #F5F5F5; -} -div, fieldset { - border-color: #303030; - margin: 0.5em 0; - display: -webkit-box; - display: -webkit-flex; - display: flex; - justify-content: space-around; - -webkit-flex-direction: row; - flex-direction: row; -} -fieldset > div > *, div > * { - margin: 0 0.5em; - width: 0em; - -webkit-flex-grow: 1; - flex-grow: 1; } \ No newline at end of file diff --git a/testbed/www/index.html b/testbed/www/index.html index 747907cf..3d2caeae 100644 --- a/testbed/www/index.html +++ b/testbed/www/index.html @@ -9,84 +9,60 @@ Branch Testing -

-
- Branch Universal Object -
- -
-
-
-
-
- Branch Deep Link -
- -
-
+
+ Branch Universal Object + +
+
+ Branch Deep Link + +
-
-
- -
-
-
-
-
- Branch Deep Link Data -
- - -
-
-
-
-
- Branch Content -
- - -
-
-
-
-
- Branch User -
- -
-
- - -
-
-
-
-
- Branch Event -
- -
-
- - -
-
-
-
-
- Branch Referral -
- - -
-
- - -
-
-
+ + + +
+ Branch Deep Link Data +
+ + +
+
+
+ Branch Content +
+ + +
+
+
+ Branch User + +
+ + +
+
+
+ Branch Event + +
+ + +
+
+
+ Branch Referral +
+ + +
+
+ + +
+