Unique Identification of iOS device for iOS 7.0 and above
Since iOS 7 it is no longer possible to get any unique device identifiers.
Your options are:
- create your own unique ID and save it in the keychain.
- use the vendor ID, which will be reset if all the app by the same vendor are removed from the device.
Getting two different device IDs from same iphone
one easiest way is to solve this issue by storing the identifierForVendor in keychain. even if you uninstall app ,value for the key remains same and its unchanged. many third party libraries available to perform this . one of them https://github.com/jrendel/SwiftKeychainWrapper.
func getGlobalUniqueIdentifierFromKeyChain()->String{
let retrievedString: String? = KeychainWrapper.standard.string(forKey: "DeviceId")
if retrievedString == nil{
if let deviceKey = UIDevice.current.identifierForVendor?.uuidString{
let _ = KeychainWrapper.standard.set(deviceKey, forKey: "DeviceId")
}
}
if let globalID = KeychainWrapper.standard.string(forKey: "DeviceId"){
return globalID
}else{
return UIDevice.current.identifierForVendor?.uuidString ?? ""
}
}
How can you uniquely identify an iOS device?
The closest thing we have to the uuid is the vendor id now
iOS7 - Device unique identifier
3) Any other suggestions...
You should consider strategies for identifying and authorizing the user instead of the device. Depending on a device-specific identifier prevents authorized users from switching devices without some sort of administrator interaction, and allows non-authorized users access if they happen to find/steal/borrow an authorized device. You can avoid these problems by relying on user credentials instead of device identifiers.
How to identify iOS device uniquely instead of using UUID and UDID
Apple has done away with the approach of UDIDs and will reject apps that use the same for unique device identification.
Source: TNW
What you are looking for is Vendor ID
How to get unique id in iOS device?
You can no longer get a unique ID per device. identifierForVendor
is the best you're going to get. Apple has systematically disabled identifying a specific device so that users' IDs can't be passed around by marketers.
To get the identifier ID as a string, you can use
let deviceId = UIDevice.current.identifierForVendor?.uuidString
UPDATE
If you want a universal ID then you have the option to use advertisingIdentifier
. However, if the user has limited ad tracking in their device settings then this value will simply return all zeroes.
import AdSupport
let identifierManager = ASIdentifierManager.shared()
if identifierManager.isAdvertisingTrackingEnabled {
let deviceId = identifierManager.advertisingIdentifier.uuidString
}
N.B. Apple recommends that this code only be used by companies building advertisement frameworks, rather than the app developers themselves. If you use this within your code for non-ad-related purposes then prepare to have your app rejected.
iOS 7 showing different UDIDs in different applications
You can't.
identifierForVendor
will only give you the same identifier for apps from the same developer on that device. And it's not guaranteed to be permanent; if you delete all the apps from the vendor, and then reinstall them, it's likely you'll get a different identifier.
As for your iOS6 implementation, that's not going to give you anything permanent, as the point of a UUID is to give you a unique string every time.
Related Topics
Combine Framework: How to Process Each Element of Array Asynchronously Before Proceeding
Cannot Change Search Bar Background Color
Find Object with Property in Array
How to Format a Double into Currency - Swift 3
Objective-C Declare Vars with ({ ... })
How to Make Uitextview Detect Links for Website, Mail and Phone Number
How to Set the Title of a Uibutton as Left-Aligned
Lldb (Swift): Casting Raw Address into Usable Type
Scroll Uitextfield Above Keyboard in a Uitableviewcell on a Regular Uiviewcontroller
How to Draw a Transparent Uitoolbar or Uinavigationbar in iOS7
Add Bottom Border Line to UI Textfield View in Swiftui/Swift/Objective-C/Xamarin
Toggling Privacy Settings Will Kill the App
Crashlytics: "We'Re Missing a Dsym to Process Crashes"
How to Use Subscript and Superscript in Swift