iOS 获取手机的型号,系统版本,软件名称,软件版本,手机ip地址

获取手机IP地址的方法:


然后写一个方法如下:

//获取手机ip地址

+(NSString *)getiPhoneIPAddresses{

    int sockfd =socket(AF_INET,SOCK_DGRAM, 0);

    NSMutableArray *ips = [NSMutableArray array];

    int BUFFERSIZE =4096;

    struct ifconf ifc;

    char buffer[BUFFERSIZE], *ptr, lastname[IFNAMSIZ], *cptr;

    struct ifreq *ifr, ifrcopy;

    ifc.ifc_len = BUFFERSIZE;

    ifc.ifc_buf = buffer;

    if (ioctl(sockfd,SIOCGIFCONF, &ifc) >= 0){

        for (ptr = buffer; ptr < buffer + ifc.ifc_len; ){

            ifr = (struct ifreq *)ptr;

            int len =sizeof(struct sockaddr);

            if (ifr->ifr_addr.sa_len > len) {

                len = ifr->ifr_addr.sa_len;

            }

            ptr += sizeof(ifr->ifr_name) + len;

            if (ifr->ifr_addr.sa_family !=AF_INET) continue;

            if ((cptr = (char *)strchr(ifr->ifr_name,':')) != NULL) *cptr =0;

            if (strncmp(lastname, ifr->ifr_name,IFNAMSIZ) == 0)continue;

            memcpy(lastname, ifr->ifr_name,IFNAMSIZ);

            ifrcopy = *ifr;

            ioctl(sockfd,SIOCGIFFLAGS, &ifrcopy);

            if ((ifrcopy.ifr_flags &IFF_UP) == 0)continue;

            NSString *ip = [NSString stringWithFormat:@"%s",inet_ntoa(((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr)];

            [ips addObject:ip];

        }

    }

    close(sockfd);

    NSString *deviceIP =@"";

    for (int i=0; i < ips.count; i++){

        if (ips.count >0){

            deviceIP = [NSString stringWithFormat:@"%@",ips.lastObject];

        }

    }

    return deviceIP;

}


  1. //手机序列号  
  2.     NSString* identifierNumber = [[UIDevice currentDevice] uniqueIdentifier];  
  3.     NSLog(@"手机序列号: %@",identifierNumber);  
  4.     //手机别名: 用户定义的名称  
  5.     NSString* userPhoneName = [[UIDevice currentDevice] name];  
  6.     NSLog(@"手机别名: %@", userPhoneName);  
  7.     //设备名称  
  8.     NSString* deviceName = [[UIDevice currentDevice] systemName];  
  9.     NSLog(@"设备名称: %@",deviceName );  
  10.     //手机系统版本  
  11.     NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];  
  12.     NSLog(@"手机系统版本: %@", phoneVersion);  
  13.     //手机型号  
  14.     NSString* phoneModel = [[UIDevice currentDevice] model];  
  15.     NSLog(@"手机型号: %@",phoneModel );  
  16.     //地方型号  (国际化区域名称)  
  17.     NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];  
  18.     NSLog(@"国际化区域名称: %@",localPhoneModel );  
  19.       
  20.     NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
  21.     // 当前应用名称  
  22.     NSString *appCurName = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
  23.     NSLog(@"当前应用名称:%@",appCurName);  
  24.     // 当前应用软件版本  比如:1.0.1  
  25.     NSString *appCurVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
  26.     NSLog(@"当前应用软件版本:%@",appCurVersion);  
  27.     // 当前应用版本号码   int类型  
  28.     NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];  
  29.     NSLog(@"当前应用版本号码:%@",appCurVersionNum);

结果:

[plain]  view plain copy
  1. 2012-10-19 14:07:47.622 myDemo[5779:707] 手机序列号: 6685c75e34104be0b04c6ceb72985dc381f0f746  
  2. 2012-10-19 14:07:47.624 myDemo[5779:707] 手机别名: “spring sky”的 iPod  
  3. 2012-10-19 14:07:47.627 myDemo[5779:707] 设备名称: iPhone OS  
  4. 2012-10-19 14:07:47.629 myDemo[5779:707] 手机系统版本: 5.1.1  
  5. 2012-10-19 14:07:47.641 myDemo[5779:707] 手机型号: iPod touch  
  6. 2012-10-19 14:07:47.642 myDemo[5779:707] 国际化区域名称: iPod touch  
  7. 2012-10-19 14:07:47.643 myDemo[5779:707] 当前应用名称:myDemo  
  8. 2012-10-19 14:07:47.645 myDemo[5779:707] 当前应用软件版本:1.0.1  






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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hbblzjy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值