Always get a unique device id in iOS 7

后端 未结 7 2234
予麋鹿
予麋鹿 2020-12-12 17:36

Our iOS application is for specific users. So, we used device unique identifier for user identification. This approach works fine till iOS 6, because we are

7条回答
  •  盖世英雄少女心
    2020-12-12 18:08

    To add something to nerowolfe's answer, there is a great Keychain Wrapper named MCSMKeychainItem, that, on top of several other things, allows you to generate and retrieve Unique Device ID with single line of code:

    [MCSMApplicationUUIDKeychainItem applicationUUID];
    

    so the basic usage will be something like

    + (NSString *)deviceId {
      // load unique device ID or generate new one
      return [MCSMApplicationUUIDKeychainItem applicationUUID];
    }
    

    It works on the basis of Keychain, where it stores once-generated unique identifier (as nerowolf suggested). It's open-source and you can download it here on github.

    Note: I am not the author of the extension, nor do I in any way know him/her.

提交回复
热议问题