Skip to content

Commit

Permalink
Add back build support for macOS & watchOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed Sep 21, 2024
1 parent 0f665e5 commit 1741f15
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/TelemetryClient/SignalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ private extension SignalManager {
@objc func appWillTerminate() {
configuration.logHandler?.log(.debug, message: #function)

// run backup in background task to avoid blocking main thread while ensureing app stays open during write
#if os(watchOS) || os(macOS)
self.signalCache.backupCache()
#else
// run backup in background task to avoid blocking main thread while ensuring app stays open during write
let backgroundTaskID = UIApplication.shared.beginBackgroundTask()
DispatchQueue.global(qos: .background).async {
self.signalCache.backupCache()
Expand All @@ -160,6 +163,7 @@ private extension SignalManager {
UIApplication.shared.endBackgroundTask(backgroundTaskID)
}
}
#endif
}

/// WatchOS doesn't have a notification before it's killed, so we have to use background/foreground
Expand All @@ -185,7 +189,10 @@ private extension SignalManager {
sendTimer?.invalidate()
sendTimer = nil

// run backup in background task to avoid blocking main thread while ensureing app stays open during write
#if os(watchOS) || os(macOS)
self.signalCache.backupCache()
#else
// run backup in background task to avoid blocking main thread while ensuring app stays open during write
let backgroundTaskID = UIApplication.shared.beginBackgroundTask()
DispatchQueue.global(qos: .background).async {
self.signalCache.backupCache()
Expand All @@ -194,6 +201,7 @@ private extension SignalManager {
UIApplication.shared.endBackgroundTask(backgroundTaskID)
}
}
#endif
}
#endif
}
Expand Down

0 comments on commit 1741f15

Please sign in to comment.