@@ -18,7 +18,18 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
18
18
let type = PluginType . before
19
19
var analytics : Analytics ?
20
20
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
+
21
27
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
+
22
33
if analytics? . configuration. values. trackApplicationLifecycleEvents == false {
23
34
return
24
35
}
@@ -77,6 +88,19 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
77
88
78
89
analytics? . track ( name: " Application Backgrounded " )
79
90
}
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
+ }
80
104
}
81
105
82
106
#endif
0 commit comments