58 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Swift
		
	
	
		
		
			
		
	
	
			58 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Swift
		
	
	
|  | // SystemProperties.swift | ||
|  | // System property utilities | ||
|  | // Corresponds to SystemProperties.kt in Android implementation | ||
|  | 
 | ||
|  | import Foundation | ||
|  | import UIKit | ||
|  | 
 | ||
|  | public class SystemProperties { | ||
|  |     private static let TAG = "SystemProperties" | ||
|  |      | ||
|  |     // Read system property from UserDefaults | ||
|  |     public static func read(propName: String) -> String { | ||
|  |         let value = UserDefaults.standard.string(forKey: propName) ?? "" | ||
|  |         Logger.i(tag: TAG, message: "read System Property: \(propName)=\(value)") | ||
|  |         return value | ||
|  |     } | ||
|  |      | ||
|  |     // Write system property to UserDefaults | ||
|  |     public static func write(propName: String, value: String) { | ||
|  |         UserDefaults.standard.set(value, forKey: propName) | ||
|  |         UserDefaults.standard.synchronize() | ||
|  |         Logger.i(tag: TAG, message: "write System Property: \(propName)=\(value)") | ||
|  |     } | ||
|  |      | ||
|  |     // Get device information | ||
|  |     public static func getDeviceInfo() -> [String: String] { | ||
|  |         var systemInfo = utsname() | ||
|  |         uname(&systemInfo) | ||
|  |         let machineMirror = Mirror(reflecting: systemInfo.machine) | ||
|  |         let identifier = machineMirror.children.reduce("") { identifier, element in | ||
|  |             guard let value = element.value as? Int8, value != 0 else { return identifier } | ||
|  |             return identifier + String(UnicodeScalar(UInt8(value))) | ||
|  |         } | ||
|  |          | ||
|  |         return [ | ||
|  |             "model": identifier, | ||
|  |             "os_version": UIDevice.current.systemVersion, | ||
|  |             "device_name": UIDevice.current.name, | ||
|  |             "device_model": UIDevice.current.model, | ||
|  |             "system_name": UIDevice.current.systemName | ||
|  |         ] | ||
|  |     } | ||
|  |      | ||
|  |     // Get app information | ||
|  |     public static func getAppInfo() -> [String: String] { | ||
|  |         let bundle = Bundle.main | ||
|  |         let appVersion = bundle.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown" | ||
|  |         let buildNumber = bundle.infoDictionary?["CFBundleVersion"] as? String ?? "Unknown" | ||
|  |         let bundleId = bundle.bundleIdentifier ?? "Unknown" | ||
|  |          | ||
|  |         return [ | ||
|  |             "app_version": appVersion, | ||
|  |             "build_number": buildNumber, | ||
|  |             "bundle_id": bundleId | ||
|  |         ] | ||
|  |     } | ||
|  | } |