Skip to content

Commit e1bd73f

Browse files
authored
Tightened up application opened events to prevent duplicates (#267)
1 parent efc111b commit e1bd73f

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,34 +77,28 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
7777
let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
7878
let currentBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String
7979

80-
analytics?.track(name: "Application Opened", properties: [
81-
"from_background": true,
82-
"version": currentVersion ?? "",
83-
"build": currentBuild ?? ""
84-
])
80+
if didFinishLaunching == false {
81+
analytics?.track(name: "Application Opened", properties: [
82+
"from_background": true,
83+
"version": currentVersion ?? "",
84+
"build": currentBuild ?? ""
85+
])
86+
}
8587
}
8688

8789
func applicationDidEnterBackground(application: UIApplication?) {
90+
didFinishLaunching = false
8891
if analytics?.configuration.values.trackApplicationLifecycleEvents == false {
8992
return
9093
}
91-
9294
analytics?.track(name: "Application Backgrounded")
9395
}
9496

9597
func applicationDidBecomeActive(application: UIApplication?) {
9698
if analytics?.configuration.values.trackApplicationLifecycleEvents == false {
9799
return
98100
}
99-
100101
analytics?.track(name: "Application Foregrounded")
101-
102-
// Lets check if we skipped application:didFinishLaunchingWithOptions,
103-
// if so, lets call it.
104-
if didFinishLaunching == false {
105-
// Call application did finish launching
106-
self.application(nil, didFinishLaunchingWithOptions: nil)
107-
}
108102
}
109103
}
110104

0 commit comments

Comments
 (0)