本文介绍了iOS 7访问企业应用程序中的UUID值(不适用于AppStore)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自iOS7以来,Apple已弃用且无法使用属性 -uniqueIdentifier 。其他属性 -identifierForVendor -advertisingIdentifier 有一个很大的问题,他们在卸载并重新安装应用程序后更改了值。

我需要该值来唯一地标识连接到服务器的设备。

应用程序将仅使用企业帐户在内部分发,因此审核过程没有问题。

Apple since iOS7 ha deprecated and unavailable the use of the property -uniqueIdentifier. The other properties -identifierForVendor and -advertisingIdentifier have the big problem that they change the value after uninstalling and reinstalling the app.
I need that value to identify uniquely the device connected to the server.
The app will be distributed only internally using an enterprise account, so no problem for the review process.

是否有私人方法可以获得它?

Is there a private a method to get it?



[更新]有一些测试]

正如大卫所说我在iOS7.1设备上使用了供应商的标识符这里是我测试的一些结果。


[UPDATE WITH SOME TEST]
As David said I used identifier for vendor on iOS7.1 device here are some results from my tests.


  • 应用安装后:28FD42B6-A993-4602-A988-69E375A1F913

  • 杀死应用后:28FD42B6-A993-4602-A988-69E375A1F913

  • 删除并重新安装应用程序后:
    28FD42B6-A993-4602-A988-69E375A1F913

  • 系统还原并重新安装应用程序后:
    4948F77F-3D41-4933-B2F0-C4DCB529C7CC

  • 从系统还原前的备份恢复后:
    28FD42B6-A993-4602-A988-69E375A1F913

  • After app installation: 28FD42B6-A993-4602-A988-69E375A1F913
  • After killing the app: 28FD42B6-A993-4602-A988-69E375A1F913
  • After deleting and reinstalling the app:28FD42B6-A993-4602-A988-69E375A1F913
  • After system restore and reinstalling the app:4948F77F-3D41-4933-B2F0-C4DCB529C7CC
  • After restore from backup made before system restore:28FD42B6-A993-4602-A988-69E375A1F913

推荐答案

您应该可以使用 [UIDevice identifierForVendor] 来达到目的。根据文档:

You should be able to use [UIDevice identifierForVendor] for your purpose. According to the documentation:

基于此,如果您删除并重新安装应用程序,我认为该值不应该更改。一些快速测试证实它在删除/安装周期中是持久的。

Based on that I don't think the value should change if you delete and reinstall the application. Some quick testing confirms that it is persistent through delete/install cycles.

编辑:

它看起来像 identifierForVendor 仅在iOS 7上通过删除/安装持久化,因此在iOS 6上使用uniqueIdentifier,在iOS 7上使用identifierForVendor:

It looks like identifierForVendor is only persistent through remove/install on iOS 7, so use uniqueIdentifier on iOS 6 and identifierForVendor on iOS 7 as:

@implementation UIDevice (persistentDeviceIdentifier)

-(NSString*)persistentDeviceIdentifier
{
    if([self respondsToSelector:@selector(uniqueIdentifier)])
        return [self performSelector:@selector(uniqueIdentifier)];
    else
        return [[self identifierForVendor] UUIDString];
}

@end

这篇关于iOS 7访问企业应用程序中的UUID值(不适用于AppStore)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:23