Is there a way since (iOS 7's release) to get the UDID without using iTunes on a PC/Mac?

后端 未结 18 1584
余生分开走
余生分开走 2020-11-28 02:55

I\'m developing an app for my company and we\'re going through the process of slowly letting people into the \"beta\" by adding their iPads to the company\'s iOS Dev Center

18条回答
  •  旧巷少年郎
    2020-11-28 03:20

    We can use identifierForVendor for ios7,

    -(NSString*)uniqueIDForDevice
    {
        NSString* uniqueIdentifier = nil;
        if( [UIDevice instancesRespondToSelector:@selector(identifierForVendor)] ) { // >=iOS 7
            uniqueIdentifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
        } else { //<=iOS6, Use UDID of Device       
                CFUUIDRef uuid = CFUUIDCreate(NULL);
                //uniqueIdentifier = ( NSString*)CFUUIDCreateString(NULL, uuid);- for non- ARC
                uniqueIdentifier = ( NSString*)CFBridgingRelease(CFUUIDCreateString(NULL, uuid));// for ARC
                CFRelease(uuid);
             }
        }
    return uniqueIdentifier;
    }
    

    --Important Note ---

    UDID and identifierForVendor are different:---

    1.) On uninstalling  and reinstalling the app identifierForVendor will change.
    
    2.) The value of identifierForVendor remains the same for all the apps installed from the same vendor on the device.
    
    3.) The value of identifierForVendor also changes for all the apps if any of the app (from same vendor) is reinstalled.
    

提交回复
热议问题