iOS 10中是否有新的设备标识符? [英] Are there new device identifiers in iOS 10?

查看:197
本文介绍了iOS 10中是否有新的设备标识符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Has anyone found a new way to uniquely identify a device in iOS 10? I haven't seen any documentation mentioning changes in that area and I wanted to ask before I surrendered to identifier for vendor.

推荐答案

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

If you're submitting to the store, the only real identifier you have left is the Advertising Identifier for the AdSupport framework.

如果您想沿着兔子洞走下去更进一步,并可能进入一些不安全的API领域,您可以挂钩到IOKit并尝试获取设备上的电池标识符。这取自Anthony Agatiello gist UIDevice 扩展名:

If you want to go down the rabbit hole a little further and potentially go into some unsafe API territory, you could hook into IOKit and try to get the battery identifier on the device. This is taken from Anthony Agatiello gist of UIDevice extensions:

- (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。

This still works on iOS 10.

这篇关于iOS 10中是否有新的设备标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆