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