Unique iOS Device ID Across Applications [duplicate] - ios

This question already has answers here:
UIDevice uniqueIdentifier deprecated - What to do now?
(32 answers)
Closed 9 years ago.
I'm currently working on a suite of iOS applications that will be using the same server for authentication. The server uses a UDID for device authentication. I'm aware that uniqueIdentifier is now deprecated, so I'm wondering what the best practice is for having a unique identifier across applications? (I know how to generate my own and store it in the keychain, but this will be application specific) I have seen postings about identifierForVendor and identifierForAdvertising

The docs say:
[uniqueIdentifier is] deprecated in iOS 5.0. Use the identifierForVendor property of this class or the advertisingIdentifier property of the ASIdentifierManager class instead, as appropriate, or use the UUID method of the NSUUID class to create a UUID and write it to the user defaults database.

As we know uniqueIdentifier is deprecated in iOS 5.0 so docs recommend you to use CFUUID
instead.
You can get CFUUID using
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidString = (NSString *)CFUUIDCreateString(NULL,uuidRef);
CFRelease(uuidRef);
Please save the uuidString in user defaults or in other place because you can not generate the same uuidString again.
Hope it helps you.

Related

How to identify device uniquely, UUID is changing for every installation of the app [duplicate]

This question already has answers here:
UIDevice currentDevice identifierForVendor - can this change on an iPad
(5 answers)
Closed 4 years ago.
My server wants to track unique number of devices.
But UIDevice.current.identifierForVendor?.uuidString is changing for each installation.
Please suggest for any alternate.
As an alternative to storing a identifier in the KeyChain, you could try using the generateToken method of the DeviceCheck framework.
Using the DeviceCheck APIs, in combination with server-to-server APIs,
you can set and query two bits of data per device, while maintaining
user privacy. You might use this data to identify devices that have
already taken advantage of a promotional offer that you provide, or to
flag a device that you've determined to be fraudulent.

Check if an ios device was blocked [duplicate]

This question already has answers here:
UIDevice uniqueIdentifier deprecated - What to do now?
(32 answers)
How to preserve identifierForVendor in ios after uninstalling ios app on device?
(8 answers)
Closed 4 years ago.
Is there a way to identify a device which was blocked by my app, so they cannot create a second account?
I have read a little bit about Unique Identification and DeviceCheck, Apple's own IPA. I also considered to ask for the phone number when the user signs up, but this seems a little complicated for me and the other solutions only work if the user is kind enough no to reinstall the app.
On other approach I had was to get some information (Carrier, iPhone Name, iOS Version, iPhone Model etc.), pack it into one String and use it as an unique id, but some of this information can be changed easily and I don't think Apple would like this solution.
I am sure that there are better/simpler solutions.
(This task seems very easy in Android. I plan to use this statement: UUID.randomUUID().toString();)
That info could help:
I am planning to connect this app to Firebase.
In the best case, the solution would work from iOS 8.0 to the current iOS Version.
I am open for any kind of creative solution in Swift or Objective C.
We can achieve this by using SSKeychain. Using SSKeychain once we have set value for particular in the SSkeychain then that value will remain their even we have removed that application from your ios device.
Please check following e.g Objective- C
if([SSKeychain passwordForService:#"your application bundle identifier" account:#"user"] == nil)
{
NSString *UUID = AppDelegate.GetUUID;
[SSKeychain setPassword:UUID forService:#"your application bundle identifier" account:#"user"];
NSString *retrieveuuid = [SSKeychain passwordForService:#"your application bundle identifier" account:#"user"];
NSLog(#"retrieveuuid %#",retrieveuuid);
}
+ (NSString *)GetUUID {
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return (__bridge NSString *)string;
}

How to identify iOS device uniquely instead of using UUID and UDID [duplicate]

This question already has answers here:
Unique Identification of iOS device for iOS 7.0 and above
(6 answers)
Closed 6 years ago.
In my iOS app, I have to restrict the user to use iOS app per device. To do this I found a solution that we can use the UUID (Universally Unique Identifier) or UDID (Unique Device Identifier). But according to this answer I can't use UUID, because if app gets deleted or reinstalled UUID has been getting changed and I don't want this. Also Apple rejects apps if app uses UDID.
Is there any way to identify iOS device uniquely.
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
I'm using this library for my projects, and it's working like a charm, please try :
https://github.com/blackpixel/BPXLUUIDHandler
easy to use :
Import BPXLUUIDHandler.h
Retrieve the UUID with
[BPXLUUIDHandler UUID]
Thats all...
Here is some info from project's github page :
As of iOS 5, Apple has deprecated the device unique identifier api and
hasn’t provided a friendly Obj-C replacement, instead recommending
CFUUIDCreate and NSUserDefaults.
CFUUIDCreate isn’t very complicated and neither is NSUserDefaults, but
this solution fails in a few different ways:
It’s not a quick one-shot call to get the UUID; you have to write your own wrapper to make it friendly
It doesn’t persist; deleting the app blows away the UUID (can be persisted if stored in the keychain though)
There’s no way to share it between apps

Regarding Unique identifier in iOS app [duplicate]

This question already has answers here:
UIDevice uniqueIdentifier deprecated - What to do now?
(32 answers)
Closed 9 years ago.
Actually the requirement is I have to create the Unique identifier for our iOS app.
This id should be still unique in the following scenarios.
App is killed and restarted again?
Data is cleared from settings and restarted again?
App is re-installed again?
OS is updated? Ex: iOS 6 to 7
Phone is factory reset?
So now there is no use of UDID which has been deprecated.
I am planing to use "device macaddress + app bundleidetifier" with md5 encryption.
Is this correct approach ? If NO kindly give me you suggestions.
Apple won't let you use any identifier that might be shared between the current owner of the device and a future owner, or if the user doesn't want to share it. Because of that Apple, has introduced an "advertising identifier" that does most of the things you want (except for the factory reset):
[[ASIdentifierManager sharedManager] advertisingIdentifier]
If there were other ways to get a device ID, Apple will probably try to block them.

Alternative way to create lifetime unique id

I want to create UDID for iphone/ipad device which will remain unchanged, so please tell me if any one have idea for that?
I have search around google and stack-overflow, but not got solution.
Also some suggested to use OpenUDID and CFUUID, but CFUUID will be different when users delete and reinstall your app. But i want to use same UDID per application which will generated at first time and should remain unchanged for lifetime per device for each application.
EDIT 2
Because of iOS upgrade and as per new documentation identifierForVendor does not retain value on app re-installs. I have seen answer at this link. This may help in one or other way. Just to note only UDID will retain even if system reset, So probably this answer can become limitation for developers seeking for lifetime UDID even on system reset. Other than this, mentioned answer seems useful.
Also look the summary here.
identifierForVendor is available from UIDevice Class Reference.
The value of this property is the same for apps that come from the
same vendor running on the same device.
[[UIDevice currentDevice] identifierForVendor].UUIDString
Note: Available in iOS 6.0 and later.
EDIT 1 As per new release of UIDevice Class Reference
The value in this property remains the same while the app (or another
app from the same vendor) is installed on the iOS device. The value
changes when the user deletes all of that vendor’s apps from the
device and subsequently reinstalls one or more of them. Therefore, if
your app stores the value of this property anywhere, you should
gracefully handle situations where the identifier changes.
EDIT
I would like you to see at this popular link
1) MD5 of MAC+CFBundleIdentifier
[[UIDevice currentDevice] uniqueDeviceIdentifier]
This will remain same per app but different for each app. If you delete and reinstall your app it will be same per app.
2) MD5 of the MAC
[[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]
This will remain same for all app from same device. If you delete and reinstall your app it will be same per device.
EDIT 3
Note: This solution in iOS 7 is no longer useful as uniqueIdentifier is no longer available from iOS7.
Its important to note the difference between a UDID and a UUID.
UDID "unique device id" is hardware specific. It never changes for a particular device. For this reason, it has become a privacy concern and Apple is blocking apps that try to use this. As a result, Apple has generated an opt-out-able "device id" hash, particularly for advertisement usage. This new ID hash is called IFA and is available in iOS 6.0+.
UUID "universally unique id" is not hardware specific. It is a hash used to identify a device; but not particularly an absolute value. For example, PhoneGap generates a UUID based on device properties; this is what you get when you do device.uuid. If you delete the app and reinstall, you will get a new id hash. UUID is not being blocked by Apple.
I think the best solution is to use the IFA, with OpenUDID as a backup for iOS < 6.0.
Here is the code we use. If IFA is not available, get OpenUDID. [[You must install OpenUDID, read more about that here, https://github.com/ylechelle/OpenUDID.]]
NSString* uuid = nil;
if ([[UIDevice currentDevice] respondsToSelector:#selector(identifierForVendor)]) {
// IOS 6 new Unique Identifier implementation, IFA
uuid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
// Before iOS6 (or if IFA disabled) you shoud use a custom implementation for uuid
// Here I use OpenUDID (you have to import it into your project)
// https://github.com/ylechelle/OpenUDID
NSString* openUDID = [OpenUDID value];
uuid = [OpenUDID value];
}
Generate an UUID (using the CFUUIDRef API, perhaps) for the first time, and store it in the keychain.

Resources