Closed palmin closed 1 year ago
In case anyone else runs into similar problems I had to do two things to solve this.
I had to take care to call TelemetryManager.initialize
on the main thread as the thread that launches a file provider has no run-loop breaking the timer that sends out events.
To make sure unsent events are cached when extension closes I had to manually send out notifications in NSFileProviderExtension.invalidate()
making it look like the app was closing.
#if os(macOS)
NotificationCenter.default.post(name: NSApplication.willTerminateNotification, object: nil)
#elseif os(iOS)
NotificationCenter.default.post(name: UIApplication.didEnterBackgroundNotification, object: nil)
#endif
Fantastic, thank you!
My app is extension centric with much of the work it performs happening outside the main app in file-provider and share extensions.
I can't seem to get events to be delivered from extensions even through I do the same TelemetryManager initialization when extensions launch as I do in applicationDidLaunch for the main app.
Looking superficially through the source code it looks like it could be problematic that extensions never enter or leave foreground mode.
Is there anything special I can do to get event delivery working from extensions?