Unique identifier for an iPhone app

后端 未结 13 1178
南笙
南笙 2020-11-29 18:33

For an iPhone app that submits images to a server I need somehow to tie all the images from a particular phone together. With every submit I\'d like to send some unique pho

相关标签:
13条回答
  • 2020-11-29 18:50

    Use Apple's GenericKeyChain which is the best solution . Here is the working sample >>https://developer.apple.com/library/prerelease/ios/samplecode/GenericKeychain/Introduction/Intro.html

    Have idea about KeyChainAccess >>https://developer.apple.com/library/mac/documentation/Security/Conceptual/keychainServConcepts/02concepts/concepts.html#//apple_ref/doc/uid/TP30000897-CH204-TP9

    0 讨论(0)
  • 2020-11-29 18:52

    Haven't done iphone work, but how about taking a hash of something unique to the phone ... oh, say the phone number?

    Getting iphone number

    0 讨论(0)
  • 2020-11-29 18:56

    You can also use CFUUID to generate a UUID. Here's some code:

    NSString *uuid = nil;
    CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
    if (theUUID) {
      uuid = NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID));
      [uuid autorelease];
      CFRelease(theUUID);
    }
    
    0 讨论(0)
  • 2020-11-29 18:56

    snippit:

    NSString *phoneNumber = (NSString *) [[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"]; // Will return null in simulator!
    NSLog(@"Formatted phone number [%@]", phoneNumber);
    

    I [recently] ran this code as-is on OS 2.2.1 [and OS 3.0].

    It works as expected when run on the device, and returns my phone number with the full international dialing codes [ 1 in my case].

    When run on the simulator, the value [returned] is a null string, so it only works on an actual iPhone device.

    I did not test it on an iPod Touch.

    ...

    Ran this code on a different device this week, and got a null value instead of the number.

    On further research, it appears that the number returned by this code snippit is the number that is set up in iTunes for the device.

    If you didn’t enter the iPhone’s number in iTunes at device activation, or perhaps (as in my case) if the default value wasn’t the iPhone’s number and you clicked OK anyway, such that iTunes doesn’t list the phone number when your iPhone is plugged in, this code will return a null string.

    [Above is an edited concatenation of comments I recently posted to another article on this topic at http://www.alexcurylo.com/blog/2008/11/15/snippet-phone-number/]

    0 讨论(0)
  • 2020-11-29 18:58

    What errors are you getting? [[UIDevice currentDevice] uniqueIdentifier] (edited to fix API, thanks Martin!) is the officially recommended way of doing this.

    0 讨论(0)
  • 2020-11-29 19:02

    This is an interesting problem that I am also looking into solving. Here is a scenario that I would like to address.

    What happens when you sell your phone to another person... that Device ID will then belong to somebody else, so even if the app is removed from the iPhone, it could be re-added and all that data would then be re-associated to a new user... this is bad.

    Using the Phone number with the Device ID MD5 would be a great solution. Another we came up with is having a SQL Lite DB with some token Hashed with the Device ID. Then when the app is removed the DB is killed and all the data is disassociated. I think that might be too brittle.

    Any other ideas?

    Rob Ellis (PhoneGap/Nitobi)

    0 讨论(0)
提交回复
热议问题