Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> iOS

วิธีสร้าง Unique Device ID สำหรับ iPhone/iPad ด้วย Swift

UDID (Unique Device Identifier) = 40 ตัวอักษร Hex ระบุอุปกรณ์ iOS

ตั้งแต่ iOS 5 Apple Deprecated UIDevice uniqueIdentifier แทนด้วย Identifier for Vendor (UUID) เหมือนกันสำหรับทุกแอปของ Developer เดียวกัน ต่าง Developer/Device

อ่านรายละเอียด

โค้ดดึง Identifier for Vendor

override func viewDidLoad() {
super.viewDidLoad()
guard let deviceID = UIDevice.current.identifierForVendor?.uuidString else { return }
print(deviceID) // 7ABAB8B5-E805-437F-9D6C-5448BB19AEA5
}