ios - 如何在 iOS 10.1.1 中读取电话号码 - Objective C/Swift

标签 ios iphone ios10 callkit

我在 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/

相关文章:

iphone - 将文件夹(带内容)从 bundle 复制到文档目录 - iOS

ios - 在WatchKit中解析查询

android - 键盘出现时钛 View 被推高

iphone - 如何禁用UIWebview中的放大镜?

ios - 贴纸包界面生成器 Storyboard编译器错误组

ios - Ionic 和 iOS 10 构建中的使用描述问题

iphone - OpenEars TTS机器人发声了吗?

iphone - 如何在obj-c/iphone应用中读取 'unrecognized selector'错误日志

iphone - 结合 TabBar 和导航 Controller 问题

ios - xib 文件中的安全区域布局指南 - iOS 10