获取设备型号,app版本,提交时间,网络类型等信息

#pragma mark 获取服务器端记录的数据
-( void )getAppInfo
{
    
content  =  _opinionTV . text ;
    
    
infoSource  =  InfoSource ; // 信息来源
    
    
tel  =  _phoneTV . text ;
    
    
qq  =  _qqTV . text ;
    
    
mail  =  _mailTV . text ;
    
    
    
    
    
// 提交时间
    
NSDate  *now = [ NSDate   date ];
    
NSCalendar  *calendar = [ NSCalendar   currentCalendar ];
    
NSUInteger  unitFlags =  NSYearCalendarUnit  |  NSMonthCalendarUnit  |  NSDayCalendarUnit  |  NSHourCalendarUnit  |  NSMinuteCalendarUnit ;
    
NSDateComponents  *dateComponents = [calendar  components :unitFlags  fromDate :now];
    
int  year = [dateComponents  year ];
    
int  month = [dateComponents  month ];
    
int  day = [dateComponents  day ];
    
int  hour = [dateComponents  hour ];
    
int  minute = [dateComponents  minute ];
    
NSLog ( @"year is: %d" , year);
    
NSLog ( @"month is: %d" , month);
    
NSLog ( @"day is: %d" , day);
    
NSLog ( @"hour is: %d" , hour);
    
NSLog ( @"minute is: %d" , minute);
    
    
// 用户 IMEI (null)
    
sc  =  _CTServerConnectionCreate ( kCFAllocatorDefault callback NULL );
    
_CTServerConnectionCopyMobileIdentity (& result sc , & imei );
    
NSLog  ( @"IMEI is %@" imei );
    
    
// OpenUDID 替代 IMEI
    
openUDID  = [ HXY_OpenUDID   value ];//导入HXY_OpenUDID文件
    
    
// 连接网络类型
    
netKind  = [ self   currentNetType ];
    
//    // 属于哪个运营商
//    NSString *carrierName = [UIDevice currentCarrierName];
    
    
// 手机型号
    
phoneModel  = [[ UIDevice   currentDevice model ];
    
NSLog ( @" 手机型号 : %@" , phoneModel  );
    
    
// 手机系统  +  系统版本号+ app 版本号
    
NSDictionary  *infoDictionary = [[ NSBundle   mainBundle infoDictionary ];
    
appVersion  = [ NSString   stringWithFormat : @"%@%@ %@" ,[[ UIDevice   currentDevice systemName ],[[ UIDevice   currentDevice systemVersion ],[infoDictionary  objectForKey : @"CFBundleShortVersionString" ]];
    
NSLog ( @" 当前 App 版本 :%@" , appVersion );
    
    
dispatch_async ( dispatch_get_main_queue (), ^{
        [
activityView   startAnimating ];

    });

    [[ NSNotificationCenter   defaultCenter postNotificationName : @"SubmitToTheServer"   object : nil ];

}



//获取当前网络类型

-(NSString *)currentNetType

{

    UIApplication *application = [UIApplication sharedApplication];

    NSArray *subviews = [[[application valueForKey:@"statusBar"] valueForKey:@"foregroundView"]subviews];

    NSNumber *dataNetWorkItemView = nil;

    for (id subView in subviews) {

        if ([subView isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {

            dataNetWorkItemView = subView;

            break;

        }

    }

    NSString *networkType = NetworkType_None;

    switch ([[dataNetWorkItemView valueForKey:@"dataNetworkType"] integerValue]) {

        case 0:

            NSLog(@"No wifi or cellular");

            networkType = NetworkType_None;

            break;

            

        case 1:

            NSLog(@"2G");

            networkType = NetworkType_2G;

            break;

            

        case 2:

            NSLog(@"3G");

            networkType = NetworkType_3G;

            break;

        case 3:

            NSLog(@"4G");

            networkType = NetworkType_4G;

        default://5

            NSLog(@"Wifi");

            networkType = NetworkType_wifi;

            break;

    }

    return networkType;

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值