Skip to content

Commit e701919

Browse files
authored
Merge pull request #363 from BranchMetrics/fix-double-open-on-ios-background
Fix double open on iOS background
2 parents 2e56e22 + 9f09a37 commit e701919

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
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.9",
5+
"version": "2.6.10",
66
"homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking",
77
"repository": {
88
"type": "git",

plugin.template.xml

Lines changed: 1 addition & 2 deletions
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.9">
27+
version="2.6.10">
2828

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

@@ -78,7 +78,6 @@ SOFTWARE.
7878
<framework src="iAd.framework" />
7979
<framework src="SafariServices.framework" />
8080
<framework src="AdSupport.framework" />
81-
<framework src="CoreTelephony.framework" />
8281
<framework src="CoreSpotlight.framework" />
8382
<framework src="MobileCoreServices.framework" />
8483

plugin.xml

Lines changed: 1 addition & 2 deletions
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.9">
27+
version="2.6.10">
2828

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

@@ -78,7 +78,6 @@ SOFTWARE.
7878
<framework src="iAd.framework" />
7979
<framework src="SafariServices.framework" />
8080
<framework src="AdSupport.framework" />
81-
<framework src="CoreTelephony.framework" />
8281
<framework src="CoreSpotlight.framework" />
8382
<framework src="MobileCoreServices.framework" />
8483

src/branch.js

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

38+
var runOnce = true
3839
Branch.prototype.initSession = function (deepLinkDataListener) {
40+
// handle double init from onResume on iOS
41+
if (!runOnce) return
42+
runOnce = (deviceVendor.indexOf('Apple') < 0)
43+
3944
// private method to filter out +clicked_branch_link = false in deep link callback
40-
var previous = 0
4145
var deepLinkDataParser = function (deepLinkData) {
4246
var isBranchLink = '+clicked_branch_link'
4347
var isNonBranchLink = '+non_branch_link'
44-
// TODO: figure out why iOS SDK passes data twice on Ionic 2 terminated and no network connection
45-
var dataLength = JSON.stringify(deepLinkData).length
46-
var isNewData = dataLength !== previous
4748
var isBranchLinkClick = deepLinkData.hasOwnProperty(isBranchLink) && deepLinkData[isBranchLink] === true
4849
var isNonBranchLinkClick = deepLinkData.hasOwnProperty(isNonBranchLink)
4950

5051
// is +clicked_branch_link' = true || +non_branch_link
51-
if (isNewData && (isBranchLinkClick || isNonBranchLinkClick)) {
52-
// to Branch.initSession(function(data) {})
52+
if (isBranchLinkClick || isNonBranchLinkClick) {
5353
deepLinkDataListener(deepLinkData)
5454
}
55-
previous = dataLength
5655
}
5756

5857
if (!disableGlobalListenersWarnings && !deepLinkDataListener && !window.DeepLinkHandler) {

0 commit comments

Comments
 (0)