4

i am using the below code to display the UDID of the device. But its displaying the null value

i.e. 2014-05-12 11:56:06.896 LoginScreen[195:60b] deviceUDID: (null)

NSUUID *deviceId;
deviceId = [UIDevice currentDevice].identifierForVendor;
NSLog(@"deviceUDID: %@",deviceID);

Sorry to all of you. I made a silly mistake

Here NSUUID instance is deviceId and i am printing deviceID in NSLog :)

Now it is working for me. Thanks to everyone

Brijesh Singh
  • 739
  • 1
  • 6
  • 23
  • 1
    http://stackoverflow.com/questions/6993325/uidevice-uniqueidentifier-deprecated-what-to-do-now – iPatel May 12 '14 at 06:41
  • A side note: this would be UUID and not UDID: [http://nshipster.com/uuid-udid-unique-identifier/]. – Rok Jarc May 12 '14 at 06:52
  • possible duplicate of [Get UDID from beta testers iOS 7](http://stackoverflow.com/questions/19672284/get-udid-from-beta-testers-ios-7) – Arslan Ali May 12 '14 at 07:54

5 Answers5

5

In order to get UUID of the device you can use the following line of code

[[[UIDevice currentDevice] identifierForVendor] UUIDString];

But you have to check whether the app is running on simulator or on device.

hope this helps you.

Shubhendu
  • 1,081
  • 8
  • 13
3

Apple has hidden the UDID from all public APIs, starting with iOS 7. Any UDID that begins with FFFF is a fake ID.

Gajendra Rawat
  • 3,673
  • 2
  • 19
  • 36
0

Objective-C :

NSString *strUUIDValue = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    NSLog(@"strUUIDValue : %@", strUUIDValue);

Screenshot for Objective-C

Swift 2 :

let UUIDValue = UIDevice.currentDevice().identifierForVendor!.UUIDString
        print("UUID: \(UUIDValue)")

Screenshot for Swift 2

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
0
NSString *string = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; 
string = [string stringByReplacingOccurrencesOfString:@"-" withString:@""]; 
string = [NSString stringWithFormat:@"%@%@",@"FFFFFFFF",string];
Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Ravi Kumar
  • 1,356
  • 14
  • 22
-1

Try this

NSUUID *deviceId;
#if TARGET_IPHONE_SIMULATOR
deviceId = [NSUUID initWithUUIDString:@"UUID-STRING-VALUE"];
#else
deviceId = [UIDevice currentDevice].identifierForVendor;
#endif

OR

   NSString *uuid = nil;
   CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
   if (theUUID) {
    uuid = NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID));
   [uuid autorelease];
   CFRelease(theUUID);
  }