ios 使用Objective-C查找IMEI号码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19927160/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:51:55  来源:igfitidea点击:

Finding IMEI number using Objective-C

iosobjective-c

提问by sharon Hwk

I need to find a way to get the IMEI number of an iPhonedevice. This question is not a duplicate.

我需要找到一种方法来获取设备的 IMEI 号码iPhone。这个问题不是重复的。

I have gone through several forums including SO, and had no luck finding an answer.

我已经浏览了包括 SO 在内的几个论坛,但没有找到答案。

Some say Apple doesn't allow developers to see the IMEInumber (SO post), and some say to use UDIDinstead (SO post). Some say that UDIDis deprecated (in iOS 7).

有人说 Apple 不允许开发人员查看IMEI数字(SO post),有人说要UDID改用(SO post)。有人说这UDID已被弃用(在 iOS 7 中)。

I need to know the following:

我需要知道以下内容:

1.) Does Applepermit developers to retrieve the IMEInumber of the device?

1.) 是否Apple允许开发人员检索IMEI设备编号?

2.) How can i programatically do it?

2.) 我怎样才能以编程方式做到这一点?

3.) In case if Apple doesn't allow developers to gather the IMEInumber, do they provide any other unique number for the device?

3.) 如果 Apple 不允许开发人员收集IMEI号码,他们是否会为设备提供任何其他唯一号码?

4.) Some suggest to use Telephony framework. If i do so, will apple reject my application?

4.) 有人建议使用Telephony framework. 如果我这样做,苹果会拒绝我的申请吗?

回答by rckoenes

Apple does not allow you to identify a device any more.

Apple 不再允许您识别设备。

UDID, MAC addressand all other device identifiers are no longer accessible or allowed by Apple.

UDIDMAC 地址和所有其他设备标识符不再被 Apple 访问或允许。

Apple suggest that you use either UUID (which you will need to store your self or), identifierForVendoror advertisingIdentifier.

Apple 建议您使用 UUID(您需要存储自己的或),.identifierForVendoradvertisingIdentifier

Apple is now also rejecting app that use the advertisingIdentifierand not showing any advertisements apps.

Apple 现在也拒绝使用advertisingIdentifier并且不显示任何广告的应用程序。

Any means to get the IMEI number are using private methods, which is also not allowed by Apple anymore. And your mobile app might/will get rejected because of this.

任何获取 IMEI 号码的方法都是使用私有方法,这也是 Apple 不再允许的。并且您的移动应用程序可能/将因此被拒绝。

回答by Jason

Unfortunately, there is no way to get a unique identifier for a device which will always remain the same. Apple no longer allows you to access the UDID. And in iOS 7, all devices' MAC addresses return the same value, so that is no longer useful either.

不幸的是,无法获得始终保持不变的设备的唯一标识符。Apple 不再允许您访问 UDID。而在 iOS 7 中,所有设备的 MAC 地址都返回相同的值,因此也不再有用。

However, iOS does now give access to two types of identifiers which can be used to identify a device. They are:

但是,iOS 现在确实允许访问可用于识别设备的两种类型的标识符。他们是:

  1. Vendor ID - [UIDevice identifierForVendor]. This is a unique identifier which is the same for all apps from the same vendor or company. It will remain the same, so long as the user has at least one app from the vendor installed on their device. So if you have 3 apps, the vendor ID will remain the same unless the user uninstalls all three apps, and then reinstalls. This is not so useful if you only have one app - if the user deletes it and then reinstalls it, it will change.

  2. Advertiser ID - [UIDevice advertisingIdentifier]. This is a unique identifier meant for advertising purposes. But if you use it for non-advertising purposes they, for the most part, won't care. Under most circumstances, the advertising identifier will not change, even if the user deletes and reinstalls the app. However, there is an option in the iOS settings to reset the advertising identifier, which will change it. This is meant to that users can choose to disassociate themselves from any advertising information which has been collected about them. But this is a very advanced setting and I doubt that many users would do this frequently enough that it would be a problem for you.

  1. 供应商 ID - [UIDevice identifierForVendor]. 这是一个唯一标识符,对于来自同一供应商或公司的所有应用程序都是相同的。只要用户在他们的设备上至少安装了一个供应商提供的应用程序,它就会保持不变。因此,如果您有 3 个应用程序,供应商 ID 将保持不变,除非用户卸载所有三个应用程序,然后重新安装。如果您只有一个应用程序,这不是很有用 - 如果用户删除它然后重新安装它,它就会改变。

  2. 广告商 ID - [UIDevice advertisingIdentifier]. 这是用于广告目的的唯一标识符。但是,如果您将其用于非广告目的,他们在大多数情况下不会在意。在大多数情况下,即使用户删除并重新安装应用程序,广告标识符也不会改变。但是,iOS 设置中有一个选项可以重置广告标识符,这将更改它。这意味着用户可以选择将自己与收集到的有关他们的任何广告信息分离。但这是一个非常高级的设置,我怀疑许多用户是否会经常这样做,以至于这对您来说是个问题。

回答by Guntis Treulands

You can obtain IMEI using private frameworks -See this Questionbut probably your app will be rejected from app store then.

您可以使用私有框架获取 IMEI -请参阅此问题,但您的应用可能会被应用商店拒绝。

If you want to obtain some device identifier to use in your application you must use uniqueIdentifier property defined in UIDevice class

如果您想获得一些设备标识符以在您的应用程序中使用,您必须使用 UIDevice 类中定义的 uniqueIdentifier 属性

(Available in iOS 6.0 and later):

(适用于 iOS 6.0 及更高版本):

NSString *UDID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

回答by Fr4ncis

If you want to obtain the IMEI there is no way (on a non-jailbroken device). If you wish to identify the user take a look at this answer. Please pay attention to all documentation/answers written before iOS7 since things have changed.

如果您想获得 IMEI,则没有办法(在非越狱设备上)。如果您想识别用户,请查看此答案。由于情况发生了变化,请注意在 iOS7 之前编写的所有文档/答案。

回答by Erumaru

You can save UUID in keychain and user it as unique number. It won't change until user will reset iOS.

您可以将 UUID 保存在钥匙串中并将其用作唯一编号。在用户重置 iOS 之前它不会改变。