Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get unique id in iOS device?

Tags:

ios

I have used mac address to identify iOS devices in server side. When run my application with iOS 7 unable to retrieve the correct mac address. Alternately i used

NSUUID *oNSUUID = [[UIDevice currentDevice] identifierForVendor]; [strApplicationUUID setString:[oNSUUID UUIDString]]; 

property. But this value also changed after every new installation of application. Now i want detect particular device in server side? How can i get some unique id per device in iOS?

like image 522
Gowtham R Avatar asked Oct 16 '13 11:10

Gowtham R


People also ask

Is device ID unique iOS?

Every iPhone, iPod touch and iPad has a unique identifier number associated with it, known as a UDID (Unique Device ID). Your UDID is a 40-digit sequence of letters and numbers that looks like this: 00000000-000000000000000.

How can I get new device ID in iOS?

To generate a new device ID for iOS, you must factory reset your device. Go to Settings > General > Reset > Reset all Contents and Settings (the device will now effectively be restored to factory settings). Reinstall your app, open it and test the Push Pre-Permissions.

Is iOS UUID unique?

UUID (Universally Unique Identifier): A sequence of 128 bits that can guarantee uniqueness across space and time, defined by RFC 4122. UDID (Unique Device Identifier): A sequence of 40 hexadecimal characters that uniquely identify an iOS device (the device's Social Security Number, if you will).

How do I find my unique mobile ID?

* getDeviceId() returns the unique device ID. * For example,the IMEI for GSM and the MEID or ESN for CDMA phones. * getSubscriberId() returns the unique subscriber ID, * For example, the IMSI for a GSM phone.


Video Answer


2 Answers

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.

like image 163
Guy Kogus Avatar answered Oct 06 '22 19:10

Guy Kogus


The best way to get the device id is identifierForVendor

UIDevice *device = [UIDevice currentDevice];  NSString  *currentDeviceId = [[device identifierForVendor]UUIDString]; 

UPDATE

For Swift 4.1 use

UIDevice.current.identifierForVendor?.uuidString 
like image 32
RajeshRam Avatar answered Oct 06 '22 20:10

RajeshRam