SwiftSDK icon indicating copy to clipboard operation
SwiftSDK copied to clipboard

[iOS] "newSessionBegan" is not tracked on app launch for older apps without `SceneDelegate`

Open dreymonde opened this issue 2 years ago • 2 comments

Quoting the code:

    /// If `true`, sends a "newSessionBegan" Signal on each app foreground or cold launch
    ///
    /// Defaults to true. Set to false to prevent automatically sending this signal.
    public var sendNewSessionBeganSignal: Bool = true

It relies on UIApplication.willEnterForegroundNotification, and, for some reason, allegedly since iOS 14 for apps that do not support SceneDelegate, this notification is not fired on launch, puzzlingly. And considering that there are still many such apps like it out there, I think this should be addressed.

I've made a simple minimal example project that reproduces this issue. Setting a breakpoint at func processSignal(_ signalType: TelemetrySignalType, for clientUser: String? = nil, floatValue: Double? = nil, with additionalPayload: [String: String] = [:], configuration: TelemetryManagerConfiguration) will quickly show that the event is not being fired

TelemetryDeckNewSessionReproduce.zip

Let me know if you have any questions

dreymonde avatar Aug 15 '23 16:08 dreymonde

For additional context: https://stackoverflow.com/questions/65618945/uiapplication-didbecomeactivenotification-not-called-ios-14

dreymonde avatar Aug 15 '23 17:08 dreymonde

Thanks for this report! I'll look into it!

winsmith avatar Aug 23 '23 15:08 winsmith