zoukankan      html  css  js  c++  java
  • 【IOS】 遍历info 所有内容 && 唯一的节能设备UUID

    /**获取装置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
    ");
        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=%@
    ",key,[infoDictionary objectForKey:key]);
        }
    
         NSString *uuid = Nil;
    //    须要用到开源类SSKeychain
    //    SSKeyChains对苹果安全框架API进行了简单封装。
    //    支持对存储在钥匙串中密码、账户进行訪问,包含读取、删除和设置。

    // SSKeyChain的作者是大名鼎鼎的SSToolkit的作者samsoffes。 // 项目地址:https://github.com/samsoffes/sskeychain // 在project中增加SSKeyChain // 在project中增加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"; }


    
        
            

    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    解决Original error: Could not proxy command to remote server. Original error: Error: socket hang up
    python各进制转换
    爬楼梯问题,yield学习总结
    微信开放平台API开发资料
    数据切分——Atlas读写分离Mysql集群的搭建
    svn SSL 错误:Key usage violation in certificate has been detected
    如何将一个空间里的内容全部复制到另一个空间,文件名不变
    SVN客户端安装 Linux
    Web端即时通讯技术盘点:短轮询、Comet、Websocket、SSE
    搭建SVN服务器
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4684089.html
Copyright © 2011-2022 走看看