Skip to content

Commit 0868dde

Browse files
committed
fix: corrected double opens on iOS background
1 parent 9389bed commit 0868dde

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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)