Skip to content

Commit

Permalink
Fix incompatibilities with watchOS and tvOS
Browse files Browse the repository at this point in the history
Fix #11
  • Loading branch information
winsmith committed Jan 5, 2021
1 parent 99a3bb2 commit 31777fc
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Sources/TelemetryClient/TelemetryClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import CommonCrypto
import UIKit
#endif

#if os(watchOS)
import WatchKit
#endif

#if os(tvOS)
import TVUIKit
#endif

public typealias TelemetrySignalType = String
public struct TelemetryManagerConfiguration {
public let telemetryAppID: String
Expand Down Expand Up @@ -135,7 +143,7 @@ private extension TelemetryManager {
#elseif os(iOS)
return "\(platform) \(UIDevice.current.systemVersion)"
#elseif os(watchOS)
return "\(platform) \(UIDevice.current.systemVersion)"
return "\(platform) \(WKInterfaceDevice.current().systemVersion)"
#elseif os(tvOS)
return "\(platform) \(UIDevice.current.systemVersion)"
#else
Expand All @@ -159,10 +167,16 @@ private extension TelemetryManager {
/// and build number (in which case it's strongly recommended to supply an email or UUID or similar identifier for
/// your user yourself.
var defaultUserIdentifier: String {
#if os(macOS)
return "unknown user \(systemVersion) \(buildNumber)"
#else
#if os(iOS)
return UIDevice.current.identifierForVendor?.uuidString ?? "unknown user \(systemVersion) \(buildNumber)"
#elseif os(watchOS)
if #available(watchOS 6.2, *) {
return WKInterfaceDevice.current().identifierForVendor?.uuidString ?? "unknown user \(systemVersion) \(buildNumber)"
} else {
return "unknown user \(platform) \(systemVersion) \(buildNumber)"
}
#else
return "unknown user \(platform) \(systemVersion) \(buildNumber)"
#endif
}

Expand Down

0 comments on commit 31777fc

Please sign in to comment.