代碼示例
//獲取當(dāng)前版本號
let currentVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
//獲取歷史版本號
let sandboxVersion = UserDefaults.standard.object(forKey: "CFBundleShortVersionString") as? String ?? ""
//版本比較
if currentVersion.compare(sandboxVersion) == ComparisonResult.orderedDescending {
//發(fā)現(xiàn)新版本 存儲當(dāng)前的版本到沙盒
UserDefaults.standard.set(currentVersion, forKey: "CFBundleShortVersionString")
}
//獲取app信息
let infoDictionary : Dictionary = Bundle.main.infoDictionary!
//程序名稱
let appDisplayName : String = infoDictionary["CFBundleDisplayName"] as! String
//版本號
let majorVersion :String = infoDictionary ["CFBundleShortVersionString"] as! String
//build號
let minorVersion :String = infoDictionary ["CFBundleVersion"] as! String
//獲取設(shè)備信息
//ios版本
let iosVersion : NSString = UIDevice.current.systemVersion as NSString
//設(shè)備udid
let identifierNumber = UIDevice.current.identifierForVendor
//設(shè)備名稱
let deviceName : String = UIDevice.current.name
//系統(tǒng)名稱
let systemName : String = UIDevice.current.systemName
//設(shè)備型號
let model = UIDevice.current.model
//設(shè)備區(qū)域化型號如A1533
let localizedModel = UIDevice.current.localizedModel
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者