IOS UUID Get

Source: Internet
Author: User

Gets the device unique ID.

The installation coverage of IOS7 is now more than 80%. IOS7 can not use the obtained Udid interface (related to privacy), a lot of people used to get the MAC address, IOS7 This interface is also obsolete, now the way is to use the UUID, but the UUID is a bad place is called every time, the generation is not the same, This will cause the UUID to change once the app loads.

So, in the first use, create a UUID, and then save the UUID and the app's ID to keychain (personal understanding should be similar to the Windows registry), the next time you need to read from keychain, so that even if the app is uninstalled, As long as the device does not reset, the UUID reads or does not change.

#import "SSKeychain.h"

 void getiosuuid (string& sretuuid)
 {
  nsstring *retrieveuuid = [SSKeychain passwordforservice:@ "Com.91.dhdar" account:@ "uuid"];
  if (Retrieveuuid = = Nil | | [Retrieveuuid isequaltostring:@ ""])
  {
   cfuuidref uuid = cfuuidcreate (NULL);
   assert (uuid! = NULL);
   cfstringref uuidstr = cfuuidcreatestring (NULL, UUID);
   retrieveuuid = [NSString stringwithformat:@ "%@", uuidstr];
   [sskeychain setpassword:retrieveuuid
                 forservice:@ "Com.game.userinfo" account:@ "uuid"];
  }
  if (retrieveuuid ~= nil)
  {
   sretuuid = [Retrieveuuid UTF8String];
  }
  else
  {
   sretuuid = "null";
  }

}

Need to use Sskeychain, download from here

Http://github.com/soffes/sskeychain

Copy the Sskeychain folder in.

=============================================

Reference:

Http://blog.woodbunny.com/post-104.html

http://blog.csdn.net/wave_1102/article/details/11894133

Http://www.cnblogs.com/howeho/p/3316573.html

Https://developer.apple.com/library/ios/samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_h.html #//apple_ref/doc/uid/dts40007797-classes_keychainitemwrapper_h-dontlinkelementid_9


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.