从iPhone上的来电中获取来电者的电话号码 [英] Get the callers phone number from an incoming call on iPhone

查看:291
本文介绍了从iPhone上的来电中获取来电者的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在来电时获取来电显示(电话号码)。
TrueCaller实现了这个,他们得到了来电者的电话号码。

I'm trying to get caller ID (phone number) at the time of incoming call. TrueCaller has implemented this and they get the phone number of incoming caller.

我发现这个信息:
1. CoreTelephony Framework(它仅给出呼叫状态)
2. Apple的9.0更新:可能联系人同步。使用邮件应用程序并检测来电号码。

I've found this information: 1. CoreTelephony Framework(It gives only calling states) 2. Apple's 9.0 update : "Maybe" contacts sync. with mail app and detects the incoming phone number.

推荐答案

###编辑###

iOS 10及以上版本:

使用 Callkit ,看一下调用目录扩展名

Use Callkit, take a look at call directory extension

根据文档,

识别来电者

Identifying Incoming Callers

当手机接到来电时,系统首先会咨询用户的联系人以查找匹配的电话号码。如果未找到匹配项,系统将查询您应用的呼叫目录分机,以查找匹配的条目以识别电话号码。这对于为与系统联系人(例如社交网络)分开的用户维护联系人列表的应用程序或用于识别可能在应用程序内发起的传入呼叫(例如,用于客户服务支持或传递通知)的应用程序非常有用。 。

When a phone receives an incoming call, the system first consults the user’s contacts to find a matching phone number. If no match is found, the system then consults your app’s Call Directory extension to find a matching entry to identify the phone number. This is useful for applications that maintain a contact list for a user that’s separate from the system contacts, such as a social network, or for identifying incoming calls that may be initiated from within the app, such as for customer service support or a delivery notification.

例如,考虑在社交网络应用中与Jane成为朋友的用户,但在她的联系人中没有她的电话号码。社交网络应用程序具有呼叫目录扩展,其下载并添加所有用户的朋友的电话号码。因此,当用户从Jane收到来电时,系统会显示(应用名称)来电显示:Jane Appleseed而非未知来电者。

For example, consider a user who is friends with Jane in a social networking app, but doesn’t have her phone number in her contacts. The social networking app has a Call Directory Extension, which downloads and add the phone numbers of all of the user’s friends. Because of this, when the user gets an incoming call from Jane, the system displays something like "(App Name) Caller ID: Jane Appleseed" rather than "Unknown Caller".

要提供有关传入呼叫者的标识信息,请在beginRequest的实现中使用addIdentificationEntry(withNextSequentialPhoneNumber:label :)方法(使用:)。

To provide identifying information about incoming callers, you use the addIdentificationEntry(withNextSequentialPhoneNumber:label:) method in the implementation of beginRequest(with:).

class CustomCallDirectoryProvider: CXCallDirectoryProvider {
    override func beginRequest(with context: CXCallDirectoryExtensionContext) {
        let labelsKeyedByPhoneNumber: [CXCallDirectoryPhoneNumber: String] = [ … ]
        for (phoneNumber, label) in labelsKeyedByPhoneNumber.sorted(by: <) {
            context.addIdentificationEntry(withNextSequentialPhoneNumber: phoneNumber, label: label)        
        }

        context.completeRequest()
    }
}

因为只有在sys时调用此方法tem启动应用程序扩展,而不是每个单独的呼叫,您必须一次性指定呼叫识别信息;例如,您不能向网络服务请求查找有关来电的信息。

Because this method is called only when the system launches the app extension and not for each individual call, you must specify call identification information all at once; you cannot, for example, make a request to a web service to find information about an incoming call.

iOS 9及更早版本

正如Kakshil所说,在非越狱设备上无法使用来电显示。

As Kakshil mentioned, Caller ID is not possible on non jailbroken devices.

我会给你一些关于真正的来电者如何工作的调查结果,

And I will give you some findings on how true caller works,


  1. 它没有读取通话记录,他们实际创建了 Action
    extension
    ,无论您何时尝试共享联系人,它都会显示
    truecaller应用程序扩展,其编码用于显示从其服务器获取的联系人
    详细信息

  1. Its not reading the call history, they actually created Action extension, wherever you try to share a contact, it will display truecaller app extension, which coded for showing the contact details fetched from their server

您可能也会因为收到少量
来电的推送通知而感到困惑,说
有些X给你打电话。这就是truecaller使用技巧的地方。如果您注意到
清楚,只有当你从安装了truecaller的android用户那里获得一个
时才会收到推送通知。让
我详细解释一下,

You might also get confused with push notification received for few calls, saying "Some X calls you". This is where truecaller used a trick. If you noticed clearly, that push notification will be received only when you get a call from an android user with truecaller installed. Let me explain you in details,

X(安装了truecaller的android用户),调用Y(安装了truecaller的ios用户),android版本通知服务器X调用Y.服务器将向Y的iPhone发送推送通知。

X(android user with truecaller installed), calling Y(ios user with truecaller installed), the android version notify the server that X making call to Y. And server will send push notification to Y's iPhone.

这篇关于从iPhone上的来电中获取来电者的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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