史上最全的iOS各種裝置資訊獲取總結

2021-07-17 05:30:22 字數 2832 閱讀 5458

github:

// 這個方法後面會列出來

nsstring*devicename= [selfgetdevicename];

nslog(@"裝置型號-->%@",devicename);

nsstring*iphonename= [uidevicecurrentdevice].name;

nslog(@"iphone名稱-->%@",iphonename);

cgfloatbatterylevel= [[uidevicecurrentdevice]batterylevel];

nslog(@"電池電量-->%f",batterylevel);

nsstring*localizedmodel= [uidevicecurrentdevice].localizedmodel;

nslog(@"localizedmodel-->%@",localizedmodel);

nsstring*systemname= [uidevicecurrentdevice].systemname;

nslog(@"當前系統名稱-->%@",systemname);

nsstring*systemversion= [uidevicecurrentdevice].systemversion;

nslog(@"當前系統版本號-->%@",systemversion);

structutsname systeminfo;

uname(&systeminfo);

nsstring*device_model= [nsstringstringwithcstring:systeminfo.machineencoding:nsutf8stringencoding];

nslog(@"device_model-->%@",device_model);

// 這個方法後面會單獨列出

nsstring*macaddress= [selfgetmacaddress];

nslog(@"macaddress-->%@",macaddress);

// 這個方法後面會單獨列出

nsstring*deviceip= [selfgetdeviceipaddresses];

nslog(@"deviceip-->%@",deviceip);

nsstring*idfa= [[[asidentifiermanagersharedmanager]advertisingidentifier]uuidstring];

nslog(@"廣告位識別符號idfa-->%@",idfa);

nsstring*uuid= [[[uidevicecurrentdevice]identifierforvendor]uuidstring];

nslog(@"唯一識別碼uuid-->%@",uuid);

// 獲取裝置型號然後手動轉化為對應名稱

- (nsstring*)getdevicename

- (nsstring*)getmacaddress

if(sysctl(mib,6,null,&len,null,0)< 0)

if((buf= malloc(len))== null)

if(sysctl(mib,6,buf,&len,null,0)< 0)

ifm= (structif_msghdr *)buf;

sdl= (structsockaddr_dl *)(ifm+ 1);

ptr= (unsignedchar*)lladdr(sdl);

nsstring*outstring= [nsstringstringwithformat:@"%02x%02x%02x%02x%02x%02x",*ptr,*(ptr+1),*(ptr+2),*(ptr+3),*(ptr+4),*(ptr+5)];

free(buf);

return[outstring uppercasestring];

}

- (nsstring*)getdeviceipaddresses

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= [nsstringstringwithformat:@"%s",inet_ntoa(((structsockaddr_in *)&ifr->ifr_addr)->sin_addr)];

[ipsaddobject:ip];}}

close(sockfd);

nsstring*deviceip= @"";

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

}returndeviceip;

}

iOS各種裝置資訊獲取總結

這個方法後面會列出來 nsstring devicename self getdevicename nslog 裝置型號 devicename nsstring iphonename uidevice currentdevice name nslog iphone名稱 iphonename cgfl...

iOS 史上最全的iOS持續整合教程 (下)

上篇介紹了打包指令碼的使用,這裡就介紹利用jenkins進行持續化整合了。這裡分為以下三個步驟介紹 安裝jenkins 配置jenkins 使用jenkins 首先需要安裝homebrew,安裝方式詳見homebrew官網。然後已命令列的方式安裝jenkins 安裝指令 brew update br...

新手必看,史上最全的iOS開發教程集錦,沒有之一!

最近大火的iphone xs max和iphone xs,不知道有沒有同學已經下手了呢?一萬三的價位確實讓很多人望而卻步啊。據說為了贏得中國的使用者,專門出了雙卡雙待的,可想而知中國市場這塊 肥肉 人人都想要。近幾年,無論蘋果出什麼樣的產品以及多高的價位,都會有非常多的蘋果 死忠粉 去購買,ios系...