/** gets the device's imie*/std::string Deviceinfo::getimie () {#if (Cc_target_platform = = Cc_platform_ios) Nsstring*bunider = nil; nsbundle* mainbundle = [NSBundle mainbundle]; nsdictionary* infodictionary = [Mainbundle infodictionary]; ID key; nsarray* keys = [Infodictionary AllKeys]; NSLog (@ "Display all keys and values in info.plist\n"); For (key in keys) {NSString * keycfbundleversion = (nsstring*) key; if ([Keycfbundleversion isequaltostring:@ "Cfbundleidentifier"]) {NSLog (@ "Bundle identifier =%@", Keycfbu Ndleversion); ID Version = [infodictionary Objectforkey:key]; Bunider = (nsstring*) version; NSLog (@ "Bunider:%@", Bunider); }//NSLog (@ "key=%@, value=%@\n", Key,[infodictionary Objectforkey:key]); } nsstring *uuid = nil;//need to use the Open source class sskeychain//sskeychains A simple encapsulation of the Apple Security Framework API,//support for passwords stored in keychain, access to accounts, including read, delete, and settings. Sskeychain's author is Samsoffes, author of the famous Sstoolkit. Project GroundAddress: Https://github.com/samsoffes/sskeychain//Add Sskeychain//In the project to add the Security.framework framework. Add SSKeychain.h and SSKEYCHAIN.M to the project folder. NSString *retrieveuuid = [Sskeychain passwordforservice:bunider account:@ "user"]; if ([Retrieveuuid length] >0) {uuid = Retrieveuuid; NSLog (@ "UUID =%@", uuid); return [UUID utf8string]; } cfstringref ref = Cfuuidcreatestring (Kcfallocatordefault, Cfuuidcreate (Kcfal Locatordefault)); UUID = (NSString *) ref; Const char* DestDir = [uuid utf8string]; Cfrelease (ref); Cclog ("uuid =%s", destDir); string sime = DestDir; Sime = Sime.substr (0,6); Log ("Sime =%s", sime.c_str ()); UUID = [NSString stringwithformat:@ "%s", Sime.c_str ()]; [Sskeychain setpassword:uuid forservice:bunider account:@ "user"]; return sime; #elif (cc_target_platform==cc_platform_android) jnimethodinfo minfo;//define JNI function information structure// The Getstaticmethodinfo function returns a bool value indicating whether this function is foundBOOL Ishave = Jnihelper::getstaticmethodinfo (Minfo, "Com/nx/deviceinfo", "Getimie", "() ljava/lang/string;"); if (ishave) {jstring jstr;jstr = (jstring) minfo.env->callstaticobjectmethod (Minfo.classid, Minfo.methodID); string Imie = jnihelper::jstring2string (JSTR); Cclog ("--------------------------------------->imie:%s", Imie.c_str ()); return Imie;} return "Androidleon"; #endif///////////////////////////////////////debugauto strings=fileutils::getinstance ()- >getvaluemapfromfile ("Debug_text.xml"); std::string debug_user_name = strings["user_name"].asstring (); if (Debug_user_name.size () >0) {CCLOG ("==use debug username== "); return debug_user_name;} return "12124124123123124wbytext";}