Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returns different OUDIDs under iPhone sim 5.1 #22

Open
mabene opened this issue Apr 3, 2012 · 3 comments
Open

Returns different OUDIDs under iPhone sim 5.1 #22

mabene opened this issue Apr 3, 2012 · 3 comments

Comments

@mabene
Copy link

mabene commented Apr 3, 2012

I'm using OpenUDID, unmodified, to replace the deprecated Apple-provided uniqueIdentifier api.

When compiling for iOS 5.1 everything works fine, except that [OpenUDID value] returns a different value every time the application is relaunched (I'm using the 5.1 Simulator). It seems unable to store the value persistently.

Going through the code with the debugger, I can see the lines:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString * guuid = (NSString *) [defaults objectForKey:kAppGUUID];

...returning always guid==nil.

Am I doing something wrong?

@mabene
Copy link
Author

mabene commented Apr 3, 2012

I was wrong; the UDID stays always the same. But it looks like the code goes through the 100-cycle loop every time the app is relaunched. Is this the intended behavior?

@jessearmand
Copy link

That's a good question. I'm curious with this loop as well. Even though this 100-cycle loop is not really a noticeable processing bottleneck.

I tried to put a break, when the availableSlotPBid is assigned:

    for (int n=0; n<kOpenUDIDRedundancySlots; n++) {
        NSString* slotPBid = [NSString stringWithFormat:@"%@%d",kOpenUDIDSlotPBPrefix,n];
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
        UIPasteboard* slotPB = [UIPasteboard pasteboardWithName:slotPBid create:NO];
#else
        NSPasteboard* slotPB = [NSPasteboard pasteboardWithName:slotPBid];
#endif
        OpenUDIDLog(@"SlotPB name = %@",slotPBid);
        if (slotPB==nil) {
            // assign availableSlotPBid to be the first one available
            if (availableSlotPBid==nil) { 
                availableSlotPBid = slotPBid;
                break;
            }
        } else {
            NSDictionary* dict = [OpenUDID _getDictFromPasteboard:slotPB];
            NSString* oudid = [dict objectForKey:kOpenUDIDKey];
            OpenUDIDLog(@"SlotPB dict = %@",dict);
            if (oudid==nil) {
                // availableSlotPBid could inside a non null slot where no oudid can be found
                if (availableSlotPBid==nil) availableSlotPBid = slotPBid;
            } else {
                // increment the frequency of this oudid key
                int count = [[frequencyDict valueForKey:oudid] intValue];
                [frequencyDict setObject:[NSNumber numberWithInt:++count] forKey:oudid];
            }
            // if we have a match with the bundleid, then let's look if the external UIPasteboard representation marks this app as OptedOut
            NSString* bid = [dict objectForKey:kOpenUDIDBIDKey];
            if (bid!=nil && [bid isEqualToString:bundleid]) {
                myRedundancySlotPBid = slotPBid;
                optedOutDate = [dict objectForKey:kOpenUDIDOOTSKey];
                optedOut = optedOutDate!=nil;
            }
        }
    }

This should be okay, right? Since it doesn't need to keep looking for available slots when one is already found.

@ylechelle
Copy link
Owner

Well, no, you need to go through the loop to find out if there has been an opt out for that bundleid/guuid... perhaps a break after the optedOut makes sense indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants