gpt4 book ai didi

ios - iOS 10 中有新的设备标识符吗?

转载 作者:行者123 更新时间:2023-12-02 05:10:25 28 4
gpt4 key购买 nike

有人在 iOS 10 中找到了唯一标识设备的新方法吗?我没有看到任何文档提到该领域的变化,我想在向供应商标识符投降之前询问一下。

最佳答案

如果您要向商店提交,您留下的唯一真实标识符是 AdSupport 框架的广告标识符。

如果您想进一步深入了解并可能进入一些不安全的 API 领域,您可以连接 IOKit 并尝试获取设备上的电池标识符。这取自 Anthony Agatiello gist UIDevice 扩展:

- (NSString *)batteryID {
void *IOKit = dlopen("/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit", RTLD_LAZY);
NSParameterAssert(IOKit);

mach_port_t *kIOMasterPortDefault = dlsym(IOKit, "kIOMasterPortDefault");
NSParameterAssert(kIOMasterPortDefault);
CFMutableDictionaryRef (*IOServiceNameMatching)(const char *name) = dlsym(IOKit, "IOServiceNameMatching");
NSParameterAssert(IOServiceNameMatching);
mach_port_t (*IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching) = dlsym(IOKit, "IOServiceGetMatchingService");
NSParameterAssert(IOServiceGetMatchingService);
kern_return_t (*IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options) = dlsym(IOKit, "IORegistryEntryCreateCFProperties");
NSParameterAssert(IORegistryEntryCreateCFProperties);
kern_return_t (*IOObjectRelease)(mach_port_t object) = dlsym(IOKit, "IOObjectRelease");
NSParameterAssert(IOObjectRelease);

CFMutableDictionaryRef properties = NULL;

mach_port_t service = IOServiceGetMatchingService(*kIOMasterPortDefault, IOServiceNameMatching("charger"));
IORegistryEntryCreateCFProperties(service, &properties, kCFAllocatorDefault, 0);

IOObjectRelease(service);
service = 0;

NSDictionary *dictionary = (__bridge NSDictionary *)properties;
NSData *batteryIDData = [dictionary objectForKey:@"battery-id"];

CFRelease(properties);
properties = NULL;

dlclose(IOKit);

return [NSString stringWithUTF8String:[batteryIDData bytes]];
}

这在 iOS 10 上仍然有效。

关于ios - iOS 10 中有新的设备标识符吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38101380/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com