How to get UDID of an iOS device programmatically in iOS 7

I use the code below to display the device UDID. But its display of zero value

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

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

Pity you all. I made a stupid mistake.

Here the NSUUID instance is deviceId and I print the device identifier in NSLog :)

Now it works for me. Thank you all

+4
source share
5 answers

To get UUIDdevices, you can use the following line of code

[[[UIDevice currentDevice] identifierForVendor] UUIDString];

But you have to check if the application works on the simulator or on the device.

Hope this helps you.

+5

Apple UDID API, iOS 7. UDID, FFFF, .

+3

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

0
source
NSString *string = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; 
string = [string stringByReplacingOccurrencesOfString:@"-" withString:@""]; 
string = [NSString stringWithFormat:@"%@%@",@"FFFFFFFF",string];
0
source

try it

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);
  }
-1
source

Source: https://habr.com/ru/post/1540179/


All Articles