Skip to content

Commit 7017650

Browse files
authored
Merge pull request #382 from BranchMetrics/more_fixes
More fixes
2 parents 4982186 + f3748a2 commit 7017650

File tree

7 files changed

+104
-102
lines changed

7 files changed

+104
-102
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "branch-cordova-sdk",
33
"description": "Branch Metrics Cordova SDK",
44
"main": "src/branch.js",
5-
"version": "2.6.14",
5+
"version": "2.6.15",
66
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
77
"repository": {
88
"type": "git",

plugin.template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="2.6.14">
27+
version="2.6.15">
2828

2929
<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->
3030

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ SOFTWARE.
2424
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
2525
xmlns:android="http://schemas.android.com/apk/res/android"
2626
id="branch-cordova-sdk"
27-
version="2.6.14">
27+
version="2.6.15">
2828

2929
<!-- DO NOT EDIT THIS FILE. MAKE ALL CHANGES TO plugin.template.xml INSTEAD -->
3030

src/android/io/branch/BranchSDK.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import android.app.Activity;
44
import android.content.Intent;
55
import android.util.Log;
6+
import android.annotation.TargetApi;
7+
import android.net.Uri;
8+
import android.os.Build;
69

710
import org.apache.cordova.CallbackContext;
811
import org.apache.cordova.CordovaPlugin;
@@ -15,8 +18,6 @@
1518
import java.util.ArrayList;
1619
import java.util.Iterator;
1720

18-
import android.net.Uri;
19-
2021
import io.branch.indexing.BranchUniversalObject;
2122
import io.branch.referral.Branch;
2223
import io.branch.referral.BranchError;
@@ -74,6 +75,23 @@ public void onNewIntent(Intent intent) {
7475

7576
}
7677

78+
/**
79+
* Handle depreciated call to sendJavaScript for more recent method
80+
*/
81+
@TargetApi(Build.VERSION_CODES.KITKAT)
82+
private void sendJavascript(final String javascript) {
83+
webView.getView().post(new Runnable() {
84+
@Override
85+
public void run() {
86+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
87+
webView.sendJavascript(javascript);
88+
} else {
89+
webView.loadUrl("javascript:" + javascript);
90+
}
91+
}
92+
});
93+
}
94+
7795
/**
7896
* <p>
7997
* cordova.exec() method reference.
@@ -808,7 +826,7 @@ public void onInitFinished(JSONObject referringParams, BranchError error) {
808826
if (error == null && referringParams != null) {
809827

810828
out = String.format("DeepLinkHandler(%s)", referringParams.toString());
811-
webView.sendJavascript(out);
829+
sendJavascript(out);
812830

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

src/branch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ Branch.prototype.disableGlobalListenersWarnings = function () {
3535
disableGlobalListenersWarnings = true
3636
}
3737

38-
var previousLinkTimestamp = null
3938
var runOnce = true
39+
var previousLinkTimestamp = null
4040
Branch.prototype.initSession = function (deepLinkDataListener) {
4141
// handle double init from onResume on iOS
4242
if (!runOnce) return new Promise(function (resolve, reject) {})
4343
runOnce = (deviceVendor.indexOf('Apple') < 0)
4444

4545
// private method to filter out +clicked_branch_link = false in deep link callback
4646
var deepLinkDataParser = function (deepLinkData) {
47+
var timestamp = '+click_timestamp'
4748
var isBranchLink = '+clicked_branch_link'
4849
var isNonBranchLink = '+non_branch_link'
49-
var timestamp = '+click_timestamp'
5050

5151
var isBranchLinkClick = deepLinkData.hasOwnProperty(isBranchLink) && deepLinkData[isBranchLink] === true
5252
var isNonBranchLinkClick = deepLinkData.hasOwnProperty(isNonBranchLink)
53-
var currentLinkTimestamp = deepLinkData.hasOwnProperty(timestamp) ? deepLinkData[timestamp] : null
53+
var currentLinkTimestamp = deepLinkData.hasOwnProperty(timestamp) ? deepLinkData[timestamp] : Date.now()
5454

5555
// is +clicked_branch_link' = true || +non_branch_link && !previousLinkTimestamp
5656
if ((isBranchLinkClick || isNonBranchLinkClick) && currentLinkTimestamp !== previousLinkTimestamp) {

testbed/www/css/index.css

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,32 @@
44
background-color: #FFFFFF;
55
}
66
body {
7-
padding: 0.8em 0em 0.2em 0em;
7+
display: flex;
8+
flex-direction: column;
9+
padding: 1em 0em 0.5em 0em;
810
max-width: 40em;
11+
margin: 0 auto;
12+
}
13+
fieldset {
14+
border-color: #303030;
15+
margin: 0.5em 1em;
16+
padding: 0.75em;
17+
}
18+
fieldset > *:not(:first-child) {
19+
margin-bottom: 0.5em;
20+
}
21+
fieldset > *:last-child {
22+
margin-bottom: 0;
23+
}
24+
section {
25+
display: flex;
26+
flex-direction: row;
27+
}
28+
section > button:nth-child(even) {
29+
margin-left: 0.5em;
30+
}
31+
section > button:nth-child(odd) {
32+
margin-right: 0.5em;
933
}
1034
button, input {
1135
padding: 0.5em;
@@ -14,20 +38,4 @@ button, input {
1438
}
1539
button {
1640
background-color: #F5F5F5;
17-
}
18-
div, fieldset {
19-
border-color: #303030;
20-
margin: 0.5em 0;
21-
display: -webkit-box;
22-
display: -webkit-flex;
23-
display: flex;
24-
justify-content: space-around;
25-
-webkit-flex-direction: row;
26-
flex-direction: row;
27-
}
28-
fieldset > div > *, div > * {
29-
margin: 0 0.5em;
30-
width: 0em;
31-
-webkit-flex-grow: 1;
32-
flex-grow: 1;
3341
}

testbed/www/index.html

Lines changed: 52 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,84 +9,60 @@
99
<title>Branch Testing</title>
1010
</head>
1111
<body>
12-
<div>
13-
<fieldset>
14-
<legend>Branch Universal Object</legend>
15-
<div>
16-
<button onclick="BranchUniversalObject()">Create</button>
17-
</div>
18-
</fieldset>
19-
</div>
20-
<div>
21-
<fieldset>
22-
<legend>Branch Deep Link</legend>
23-
<div>
24-
<input id="alias" name="alias" type="text" placeholder="Enter an alias">
25-
</div>
26-
<div>
12+
<fieldset>
13+
<legend>Branch Universal Object</legend>
14+
<button onclick="BranchUniversalObject()">Create</button>
15+
</fieldset>
16+
<fieldset>
17+
<legend>Branch Deep Link</legend>
18+
<input id="alias" name="alias" type="text" placeholder="Deep link alias (optional)">
19+
<section>
2720
<button onclick="BranchDeepLink()">Create</button>
2821
<button onclick="BranchShareSheet()">Share</button>
29-
</div>
30-
<div>
31-
<input type="text" id="generated-url" placeholder="Deep Link" readonly>
32-
</div>
33-
</fieldset>
34-
</div>
35-
<div>
36-
<fieldset>
37-
<legend>Branch Deep Link Data</legend>
38-
<div>
39-
<button onclick="BranchFirstData()">First</button>
40-
<button onclick="BranchLatestData()">Latest</button>
41-
</div>
42-
</fieldset>
43-
</div>
44-
<div>
45-
<fieldset>
46-
<legend>Branch Content</legend>
47-
<div>
48-
<button onclick="BranchView()">Create</button>
49-
<button onclick="BranchSpotlight()">Share</button>
50-
</div>
51-
</fieldset>
52-
</div>
53-
<div>
54-
<fieldset>
55-
<legend>Branch User</legend>
56-
<div>
57-
<input type="text" id="identity" name="identity" placeholder="User Id">
58-
</div>
59-
<div>
60-
<button onclick="BranchUser()">Login</button>
61-
<button onclick="BranchLogout()">Logout</button>
62-
</div>
63-
</fieldset>
64-
</div>
65-
<div>
66-
<fieldset>
67-
<legend>Branch Event</legend>
68-
<div>
69-
<input type="text" id="custom-action" name="custom-action" placeholder="Event Name">
70-
</div>
71-
<div>
72-
<button onclick="BranchEvent()">Create</button>
73-
<button onclick="BranchCommerce()">Commerce</button>
74-
</div>
75-
</fieldset>
76-
</div>
77-
<div>
78-
<fieldset>
79-
<legend>Branch Referral</legend>
80-
<div>
81-
<button onclick="BranchReferralsReward()">Reward</button>
82-
<button onclick="BranchReferralsLoad()">Load</button>
83-
</div>
84-
<div>
85-
<button onclick="BranchReferralsRedeem()">Redeem</button>
86-
<button onclick="BranchReferralsHistory()">History</button>
87-
</div>
88-
</fieldset>
89-
</div>
22+
</section>
23+
<input type="text" id="generated-url" placeholder="Deep link" readonly>
24+
</fieldset>
25+
<fieldset>
26+
<legend>Branch Deep Link Data</legend>
27+
<section>
28+
<button onclick="BranchFirstData()">First</button>
29+
<button onclick="BranchLatestData()">Latest</button>
30+
</section>
31+
</fieldset>
32+
<fieldset>
33+
<legend>Branch Content</legend>
34+
<section>
35+
<button onclick="BranchView()">Create</button>
36+
<button onclick="BranchSpotlight()">Share</button>
37+
</section>
38+
</fieldset>
39+
<fieldset>
40+
<legend>Branch User</legend>
41+
<input type="text" id="identity" name="identity" placeholder="User Id">
42+
<section>
43+
<button onclick="BranchUser()">Login</button>
44+
<button onclick="BranchLogout()">Logout</button>
45+
</section>
46+
</fieldset>
47+
<fieldset>
48+
<legend>Branch Event</legend>
49+
<input type="text" id="custom-action" name="custom-action" placeholder="Event Name">
50+
<section>
51+
<button onclick="BranchEvent()">Create</button>
52+
<button onclick="BranchCommerce()">Commerce</button>
53+
</section>
54+
</fieldset>
55+
<fieldset>
56+
<legend>Branch Referral</legend>
57+
<section>
58+
<button onclick="BranchReferralsReward()">Reward</button>
59+
<button onclick="BranchReferralsLoad()">Load</button>
60+
</section>
61+
<section>
62+
<button onclick="BranchReferralsRedeem()">Redeem</button>
63+
<button onclick="BranchReferralsHistory()">History</button>
64+
</section>
65+
</fieldset>
9066
<script type="text/javascript" src="cordova.js"></script>
9167
<script type="text/javascript" src="js/index.js"></script>
9268
</body>

0 commit comments

Comments
 (0)