diff --git a/CHANGELOG.md b/CHANGELOG.md index 94077f23..c65f48ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,7 +38,7 @@ _None._ ### New Features -_None._ +- Track whether Lockdown Mode is enabled as a device property (`device_info_lockdown_mode_enabled`). ### Bug Fixes diff --git a/Sources/Event Logging/TracksService.m b/Sources/Event Logging/TracksService.m index 813c1dde..f2c19ead 100644 --- a/Sources/Event Logging/TracksService.m +++ b/Sources/Event Logging/TracksService.m @@ -66,6 +66,7 @@ @interface TracksService () NSString *const DeviceInfoOrientation = @"device_info_orientation"; NSString *const DeviceInfoPreferredContentSizeCategory = @"device_info_preferred_content_size_category"; NSString *const DeviceInfoIsAccessibilityCategory = @"device_info_is_accessibility_category"; +NSString *const DeviceInfoLockdownModeEnabledKey = @"device_info_lockdown_mode_enabled"; NSString *const TracksEventNameKey = @"_en"; NSString *const TracksUserAgentKey = @"_via_ua"; @@ -422,6 +423,7 @@ - (NSDictionary *)mutableDeviceProperties DeviceInfoOrientation : self.deviceInformation.orientation ?: @"Unknown", DeviceInfoPreferredContentSizeCategory : self.deviceInformation.preferredContentSizeCategory ?: @"Unknown", DeviceInfoIsAccessibilityCategory : self.deviceInformation.isAccessibilityCategory ? @"YES" : @"NO", + DeviceInfoLockdownModeEnabledKey : self.deviceInformation.isLockdownModeEnabled ? @"YES" : @"NO", }; } diff --git a/Sources/Model/ObjC/Common/TracksDeviceInformation.h b/Sources/Model/ObjC/Common/TracksDeviceInformation.h index 0445e61a..ad73892d 100644 --- a/Sources/Model/ObjC/Common/TracksDeviceInformation.h +++ b/Sources/Model/ObjC/Common/TracksDeviceInformation.h @@ -41,6 +41,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) BOOL isAppleWatchConnected; @property (nonatomic, assign) BOOL isVoiceOverEnabled; @property (nonatomic, readonly) NSString *orientation; +@property (nonatomic, readonly) BOOL isLockdownModeEnabled; @end diff --git a/Sources/Model/ObjC/Common/TracksDeviceInformation.m b/Sources/Model/ObjC/Common/TracksDeviceInformation.m index 0142c538..eece2463 100644 --- a/Sources/Model/ObjC/Common/TracksDeviceInformation.m +++ b/Sources/Model/ObjC/Common/TracksDeviceInformation.m @@ -22,6 +22,8 @@ @interface TracksDeviceInformation () @property (nonatomic, assign) BOOL isReachable; @property (nonatomic, assign) BOOL isReachableByWiFi; @property (nonatomic, assign) BOOL isReachableByWWAN; +@property (nonatomic, assign) BOOL cachedLockdownModeEnabled; +@property (nonatomic, assign) BOOL hasReadLockdownMode; #if TARGET_OS_IPHONE && !TARGET_OS_WATCH @property (nonatomic, assign) UIDeviceOrientation lastKnownDeviceOrientation; @@ -249,6 +251,14 @@ - (NSString *)preferredContentSizeCategory { /// - Uses `UIContentSizeCategoryIsAccessibilityCategory` method. /// - This will be `false` for Mac OS and watchOS. /// +- (BOOL)isLockdownModeEnabled { + if (!self.hasReadLockdownMode) { + self.cachedLockdownModeEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"LDMGlobalEnabled"]; + self.hasReadLockdownMode = YES; + } + return self.cachedLockdownModeEnabled; +} + - (BOOL)isAccessibilityCategory { #if TARGET_OS_WATCH return NO;