【IOS】 遍历info 的所有内容 && 保存设备唯一UUID
2014-06-26 16:58
609 查看
/**获取设备的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 = %@",keyCFBundleVersion); id version = [infoDictionary objectForKey:key]; bunider = (NSString*)version; NSLog(@"bunider : %@",bunider); } // NSLog(@"key=%@ , value=%@\n",key,[infoDictionary objectForKey:key]); } NSString *uuid = Nil; // 需要用到开源类SSKeychain // SSKeyChains对苹果安全框架API进行了简单封装, // 支持对存储在钥匙串中密码、账户进行访问,包括读取、删除和设置。 // SSKeyChain的作者是大名鼎鼎的SSToolkit的作者samsoffes。 // 项目地址:https://github.com/samsoffes/sskeychain // 在工程中加入SSKeyChain // 在工程中加入Security.framework框架。 // 把SSKeychain.h和SSKeychain.m加到项目文件夹。 NSString *retrieveuuid = [SSKeychain passwordForService:bunider account:@"user"]; if ([retrieveuuid length] >0) { uuid = retrieveuuid; NSLog(@"uuid = %@",uuid); return [uuid UTF8String]; } CFStringRef ref = CFUUIDCreateString(kCFAllocatorDefault, CFUUIDCreate(kCFAllocatorDefault)); 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;//定义Jni函数信息结构体 //getStaticMethodInfo 次函数返回一个bool值表示是否找到此函数 bool 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 ///////////////////////////////////////debug auto 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"; }
相关文章推荐
- 【IOS】 遍历info 所有内容 && 唯一的节能设备UUID
- iOS使用keychain和uuid确定设备唯一标识
- [iOS]图片压缩&保存View为内容Img
- iOS保存密码之钥匙串操作以及UDID设备唯一标识符获取的替代方法
- iOS 获取设备唯一标示符 UDID UUID IDFA IDFV IMEI IMSI MAC地址 OpenUUID
- iOS开发-获取设备唯一标识符(UUID)
- 使用流加载和保存HTML内容&遍历html的信息存入一个ini文件&使用MSHTML分析HTML代码
- iOS利用钥匙串保存获取设备的唯一标识
- iOS--获取设备唯一标示UUID
- iOS获取设备唯一的UUID(解决删除应用UUID变更的问题)
- 【IOS】获取iOS设备唯一标识的演进UDID, MAC Address,UUID,IDFA,IDFV,OpenUDID
- ios 遍历输出所有字体
- UUID iOS设备唯一标示符
- iOS编程——通过UUID和KeyChain来代替Mac地址实现iOS设备的唯一标示(OC版)
- iOS设备唯一标识保存
- iOS设备唯一标识<二>
- ios获取和保存设备uuid
- iOS编程——通过UUID和KeyChain来代替Mac地址实现iOS设备的唯一标示(OC优化版)
- iOS中keyChain 实现UUID 设备唯一标识符碰到的问题
- iOS 所有设备一览 && CoreFoundation源码