From 542dafbe141312ec2f00f5eb61351b51581b9603 Mon Sep 17 00:00:00 2001 From: Darren Jones Date: Fri, 3 Sep 2021 12:34:12 +0100 Subject: [PATCH] Reverted watchOS back to 4.0 --- Package.swift | 2 +- Sources/TelemetryClient/Signal.swift | 2 +- Sources/TelemetryClient/TelemetryClient.swift | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 6f33f0e..27a0550 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [ .macOS(.v10_13), .iOS(.v12), - .watchOS(.v7), + .watchOS(.v4), .tvOS(.v11) ], products: [ diff --git a/Sources/TelemetryClient/Signal.swift b/Sources/TelemetryClient/Signal.swift index 8e750c0..39d3f70 100644 --- a/Sources/TelemetryClient/Signal.swift +++ b/Sources/TelemetryClient/Signal.swift @@ -133,7 +133,7 @@ extension SignalPayload { /// The modelname as reported by systemInfo.machine static var modelName: String { - if #available(iOS 14.0, *), ProcessInfo.processInfo.isiOSAppOnMac { + if #available(iOS 14.0, watchOS 7.0, *), ProcessInfo.processInfo.isiOSAppOnMac { var size = 0 sysctlbyname("hw.model", nil, &size, nil, 0) var machine = [CChar](repeating: 0, count: size) diff --git a/Sources/TelemetryClient/TelemetryClient.swift b/Sources/TelemetryClient/TelemetryClient.swift index 8d626a2..aaf4400 100644 --- a/Sources/TelemetryClient/TelemetryClient.swift +++ b/Sources/TelemetryClient/TelemetryClient.swift @@ -69,9 +69,13 @@ public final class TelemetryManagerConfiguration { #if os(iOS) NotificationCenter.default.addObserver(self, selector: #selector(didEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil) #elseif os(watchOS) + if #available(watchOS 7.0, *) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { NotificationCenter.default.addObserver(self, selector: #selector(self.didEnterForeground), name: WKExtension.applicationWillEnterForegroundNotification, object: nil) } + } else { + // Pre watchOS 7.0, this library will not use multiple sessions after backgrounding since there are no notifications we can observe. + } #elseif os(tvOS) DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { NotificationCenter.default.addObserver(self, selector: #selector(self.didEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)