ios 裝置獲取idfa iOS獲取裝置ID總結

2021-10-13 12:21:37 字數 2882 閱讀 1380

ios獲取裝置id總結

udid

獲取:[[uidevice currentdevice] uniqueidentifier]

廢棄:ios6

idfv

獲取:[[[uidevice currentdevice] identifierforvendor] uuidstring]

適用:ios6.0+

例子:95955f33-bfbd-48ba-a630-866d2dae482d

idfa

獲取:[[[asidentifiermanager sharedmanager] advertisingidentifier] uuidstring];

適用:ios6.0+

例子:9c287922-ee26-4501-94b5-dde6f83e1475

mac位址

簡介:mac位址在網路上用來區分裝置的唯一性,接入網路的裝置都有乙個mac位址,他們肯定都是不同的,是唯一的。一部iphone上可能有多個mac位址,包括wifi的、sim的等,但是itouch和ipad上就有乙個wifi的,因此只需獲取wifi的mac位址就好了,也就是en0的位址。mac位址就如同我們身份證上的身份證號碼,具有全球唯一性。但在ios7之後,如果請求mac位址都會返回乙個固定值。

廢棄:ios7.0+

獲取:- (nsstring *)macaddress

int mib[6];

size_t len;

char *buf;

unsigned char *ptr;

struct if_msghdr *ifm;

struct sockaddr_dl *sdl;

mib[0] = ctl_net;

mib[1] = af_route;

mib[2] = 0;

mib[3] = af_link;

mib[4] = net_rt_iflist;

if ((mib[5] = if_nametoindex("en0")) == 0) {

printf("error: if_nametoindex error/n");

return null;

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

printf("error: sysctl, take 1/n");

return null;

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

printf("could not allocate memory. error!/n");

return null;

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

printf("error: sysctl, take 2");

return null;

ifm = (struct if_msghdr *)buf;

sdl = (struct sockaddr_dl *)(ifm + 1);

ptr = (unsigned char *)lladdr(sdl);

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

nslog(@"outstring:%@", outstring);

free(buf);

return [outstring uppercasestring];

keychain

獲取:+ (nsstring *)uuid {

if (uuid == nil || uuid.length == 0) {

uuid = [[[uidevice currentdevice] identifierforvendor] uuidstring];

return uuid;

類:aadeviceinfo(dump出頭檔案)

@class nsobject, apsconnection, nsdata;

@inte***ce aadeviceinfo : nsobject {

apsconnection *_apsconnection;

bool _tokendone;

nsdata *_token;

nsobject *_tokensema;

+ (id)useragentheader;

+ (id)signaturewithdictionary:(id)arg1;

+ (id)apnstoken;

+ (id)serialnumber;

+ (id)clientinfoheader;

+ (id)productversion;

+ (id)osversion;

+ (id)udid;

+ (id)infodictionary;

- (id)wifimacaddress;

- (id)regioncode;

- (id)deviceclass;

- (id)osname;

- (id)producttype;

- (id)apnstoken;

- (id)serialnumber;

- (id)deviceinfodictionary;

- (id)productversion;

- (id)osversion;

- (id)udid;

- (id)init;

- (void).cxx_destruct;

- (id)buildversion;

@end

獲取:[aadeviceinfo udid]

獲取iOS裝置資訊

鑌哥就直接寫 了 獲取手機資訊 應用程式的名稱和版本號等資訊都儲存在mainbundle的乙個字典中,用下面 可以取出來 nsdictionary infodict nsbundle mainbundle infodictionary nsstring versionnum infodict obj...

iOS 獲取裝置資訊

ios 獲取裝置資訊 獲取裝置資訊,不囉嗦,直接上 uidevice idfa add adsupport.framework define kdeviceidfa asidentifiermanager sharedmanager advertisingidentifier uuidstring ...

ios獲取裝置資訊

我們寫專案的時候有時候可能會需要獲取到使用者的裝置資訊 下面用 簡要描述一下 uidevice currentdevice uidevice currentdevice nsstring strname currentdevice.name 裝置名稱 nsstring strmodel curren...