@@ -18,7 +18,18 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
1818 let type = PluginType . before
1919 var analytics : Analytics ?
2020
21+ /// Since application:didFinishLaunchingWithOptions is not automatically called with Scenes / SwiftUI,
22+ /// this gets around by using a flag in user defaults to check for big events like application updating,
23+ /// being installed or even opening.
24+ @Atomic
25+ private var didFinishLaunching = false
26+
2127 func application( _ application: UIApplication ? , didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? ) {
28+
29+ // Make sure we aren't double calling application:didFinishLaunchingWithOptions
30+ // by resetting the check at the start
31+ didFinishLaunching = true
32+
2233 if analytics? . configuration. values. trackApplicationLifecycleEvents == false {
2334 return
2435 }
@@ -77,6 +88,19 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
7788
7889 analytics? . track ( name: " Application Backgrounded " )
7990 }
91+
92+ func applicationDidBecomeActive( application: UIApplication ? ) {
93+ if analytics? . configuration. values. trackApplicationLifecycleEvents == false {
94+ return
95+ }
96+
97+ // Lets check if we skipped application:didFinishLaunchingWithOptions,
98+ // if so, lets call it.
99+ if didFinishLaunching == false {
100+ // Call application did finish launching
101+ self . application ( nil , didFinishLaunchingWithOptions: nil )
102+ }
103+ }
80104}
81105
82106#endif
0 commit comments