Joshua Davis
Joshua Davis

Reputation: 325

Does an iOS device's uuid ever change, with software updates?

Does an iOS device's uuid ever change, with software updates or anything related?

Upvotes: 2

Views: 4456

Answers (4)

hotpaw2
hotpaw2

Reputation: 70673

The UDID never changes on iOS devices running Apple's stock OS.

On devices running a rooted/modified OS, the value returned by any API could be anything a clever modifier wants it to be.

Upvotes: -1

dgund
dgund

Reputation: 3467

No it does not. It will always remain the same.

Upvotes: 0

Scott Sherwood
Scott Sherwood

Reputation: 3128

You can create your own 'UUID' which will persist for as long as your app is on the device.

+ (NSString *)localUuid {
   NSString *ident = [[NSUserDefaults standardUserDefaults] objectForKey:@"unique identifier stored for app"];
   if (!ident) {
      CFUUIDRef uuidRef = CFUUIDCreate(NULL);
      CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef);
      CFRelease(uuidRef);
      ident = [NSString stringWithString:(NSString *)uuidStringRef];
      CFRelease(uuidStringRef);
      [[NSUserDefaults standardUserDefaults] setObject:ident forKey:@"unique identifier stored for app"];
      [[NSUserDefaults standardUserDefaults] synchronize];
   }
   return ident;
}

but this does not give you a unique id that you can use across applications for obvious reasons. Another alternative is using the MAC address

#import <sys/types.h>
#import <sys/socket.h>
#import <sys/sysctl.h>
#import <sys/time.h>
#import <netinet/in.h>
#import <net/if_dl.h>
#import <netdb.h>
#import <errno.h>
#import <arpa/inet.h>
#import <unistd.hv
#import <ifaddrs.h>

#if !defined(IFT_ETHER)
   #define IFT_ETHER 0x6
#endif

@implementation MACIdentify

- (NSString*)MACAddress {
    NSMutableString* result = [NSMutableString string];

    BOOL success;
    struct ifaddrs* addrs;
    const struct ifaddrs* cursor;
    const struct sockaddr_dl* dlAddr;
    const uint8_t * base;
    int i;

    success = (getifaddrs(&addrs) == 0);
    if(success)
    {
        cursor = addrs;
        while(cursor != NULL)
        {
            if((cursor->ifa_addr->sa_family == AF_LINK) && (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER))
            {
                dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;

                base = (const uint8_t *) &dlAddr->sdl_data[dlAddr->sdl_nlen];

                for(i=0; isdl_alen; i++)
                {
                    if(i != 0)
                    {
                        [result appendString:@":"];
                    }
                    [result appendFormat:@"%02x", base[i]];
                }
            }
            cursor = cursor->ifa_next;
        }
        freeifaddrs(addrs);
    }

    return result;
}

@end

Upvotes: 0

DarkDust
DarkDust

Reputation: 92316

No, it does not change. But note that it's now deprecated (probably due to privacy concerns).

Upvotes: 2

Related Questions