我在 SO 上看到了很多关于这个的问题。所有的答案都说这是不可能的。 Apple
不允许这样做。
我正在使用 iPhone 6s
运行 iOS 10.1.1
昨天我购买了新的 Sim 卡。当我打开 WhatsApp
时插入新的 SIM 卡。我得到一个屏幕,上面写着:
`Your number has been changed. Do you want to use new number`
whatsapp 如何做到这一点?
其次,我安装了 Airtel
应用程序。当我打开应用程序时。它会自动获取我的电话号码并显示给我。
这些应用如何读取电话号码。
Apple 是在 iOS 10
中添加了新方法还是他们正在使用一些其他逻辑来这样做。
最佳答案
有一个观察者subscriberCellularProviderDidUpdateNotifier
根据文档 here
A block object that is dispatched on the default priority global dispatch queue when the user’s cellular provider information changes. This occurs, for example, if a user swaps the device’s SIM card with one from another provider, while your application is running.
To handle changes in cellular service provider information, define a block in your application and assign it to this property. The block must be implemented to support being called from any context.
这只是通知您您的 sim 卡已更改。
关于您的第二个问题,您可以使用 Contacts.framework
关于ios - 如何在 iOS 10.1.1 中读取电话号码 - Objective C/Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40906432/