diff --git a/Sources/Core/Utils/DeviceInfoMonitor.swift b/Sources/Core/Utils/DeviceInfoMonitor.swift index bbf7f05f0..75d8c0219 100644 --- a/Sources/Core/Utils/DeviceInfoMonitor.swift +++ b/Sources/Core/Utils/DeviceInfoMonitor.swift @@ -38,15 +38,15 @@ class DeviceInfoMonitor { /// Returns the current device's vendor in the form of a string. /// - Returns: A string with vendor, i.e. "Apple Inc." - var deviceVendor: String? { + var deviceVendor: String { return "Apple Inc." } /// Returns the current device's model in the form of a string. /// - Returns: A string with device model. - var deviceModel: String? { + var deviceModel: String { let simulatorModel = (ProcessInfo.processInfo.environment)["SIMULATOR_MODEL_IDENTIFIER"] - if simulatorModel != nil { + if let simulatorModel = simulatorModel { return simulatorModel } @@ -59,7 +59,7 @@ class DeviceInfoMonitor { /// This is to detect what the version of mobile OS of the current device. /// - Returns: The current device's OS version type as a string. - var osVersion: String? { + var osVersion: String { #if os(iOS) || os(tvOS) || os(visionOS) return UIDevice.current.systemVersion #elseif os(watchOS) @@ -78,7 +78,7 @@ class DeviceInfoMonitor { #endif } - var osType: String? { + var osType: String { #if os(iOS) return "ios" #elseif os(tvOS) diff --git a/Sources/Snowplow/Configurations/TrackerConfiguration.swift b/Sources/Snowplow/Configurations/TrackerConfiguration.swift index 18e6e2359..ae441d611 100644 --- a/Sources/Snowplow/Configurations/TrackerConfiguration.swift +++ b/Sources/Snowplow/Configurations/TrackerConfiguration.swift @@ -270,7 +270,7 @@ public class TrackerConfiguration: SerializableConfiguration, TrackerConfigurati public var advertisingIdentifierRetriever: (() -> UUID?)? { get { return platformContextRetriever?.appleIdfa } set { - if var retriever = platformContextRetriever { + if let retriever = platformContextRetriever { retriever.appleIdfa = newValue } else { platformContextRetriever = PlatformContextRetriever(appleIdfa: newValue) diff --git a/Sources/Snowplow/Tracker/PlaformContextRetriever.swift b/Sources/Snowplow/Tracker/PlaformContextRetriever.swift index 884142b83..4f5fc2367 100644 --- a/Sources/Snowplow/Tracker/PlaformContextRetriever.swift +++ b/Sources/Snowplow/Tracker/PlaformContextRetriever.swift @@ -17,16 +17,16 @@ import Foundation public class PlatformContextRetriever { /// Operating system type (e.g., ios, tvos, watchos, osx, android) - public var osType: (() -> String?)? = nil + public var osType: (() -> String)? = nil /// The current version of the operating system - public var osVersion: (() -> String?)? = nil + public var osVersion: (() -> String)? = nil /// The manufacturer of the product/hardware - public var deviceVendor: (() -> String?)? = nil + public var deviceVendor: (() -> String)? = nil /// The end-user-visible name for the end product - public var deviceModel: (() -> String?)? = nil + public var deviceModel: (() -> String)? = nil /// The carrier of the SIM inserted in the device public var carrier: (() -> String?)? = nil @@ -98,10 +98,10 @@ public class PlatformContextRetriever { /// - scale: Scale factor used to convert logical coordinates to device coordinates of the screen (uses UIScreen.scale on iOS) /// - language: System language currently used on the device (ISO 639) public init( - osType: (() -> String?)? = nil, - osVersion: (() -> String?)? = nil, - deviceVendor: (() -> String?)? = nil, - deviceModel: (() -> String?)? = nil, + osType: (() -> String)? = nil, + osVersion: (() -> String)? = nil, + deviceVendor: (() -> String)? = nil, + deviceModel: (() -> String)? = nil, carrier: (() -> String?)? = nil, networkType: (() -> String?)? = nil, networkTechnology: (() -> String?)? = nil, diff --git a/Tests/Utils/MockDeviceInfoMonitor.swift b/Tests/Utils/MockDeviceInfoMonitor.swift index 4ff31912b..025af1e69 100644 --- a/Tests/Utils/MockDeviceInfoMonitor.swift +++ b/Tests/Utils/MockDeviceInfoMonitor.swift @@ -23,22 +23,22 @@ class MockDeviceInfoMonitor: DeviceInfoMonitor { return customAppleIdfv } - override var deviceVendor: String? { + override var deviceVendor: String { increaseMethodAccessCount("deviceVendor") return "Apple Inc." } - override var deviceModel: String? { + override var deviceModel: String { increaseMethodAccessCount("deviceModel") return "deviceModel" } - override var osVersion: String? { + override var osVersion: String { increaseMethodAccessCount("osVersion") return "13.0.0" } - override var osType: String? { + override var osType: String { increaseMethodAccessCount("osType") return "ios" }