如何从本机 phone 最近获取 voip phone 名称描述?
How to get voip phone name description from native phone recents?
当我在本机 phone 最近的通话中选择我的应用程序拨打的电话时
但是我只能得到id(EX:12345678),无法得到描述(EX:David)
native phone recents
info of the outgoing call
这是我在 AppDelegate.m
中的代码
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler NS_AVAILABLE_IOS(8_0)
{
INInteraction *interaction = userActivity.interaction;
INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent;
INPerson *contact = startAudioCallIntent.contacts[0];
INPersonHandle *personHandle = contact.personHandle;
NSString *phoneNumber = personHandle.value;
}
我在 INPerson 对象中找不到任何关于描述(例如:David)的信息。
还有其他方法可以获取 phone 描述吗?
我认为你做不到。
配置 CXProvider 对象时,指定支持的句柄类型 (CXHandle.HandleType),例如:
providerConfiguration.supportedHandleTypes = [.phoneNumber]
When the telephony provider receives an incoming call or the user
starts an outgoing call, the other caller is identified by a CXHandle
object. For a caller identified by a phone number, the handle type is
CXHandleTypePhoneNumber and the value is a sequence of digits. For a
caller identified by an email address, the handle type is
CXHandleTypeEmailAddress and the value is an email address. For a
caller identified in any other way, the handle type is
CXHandleTypeGeneric and the value typically follows some
domain-specific format, such as a username, numeric ID, or URL.
您可以为出站调用添加通用 CXHandle:
- (instancetype)initWithType:(CXHandleType)type
value:(NSString *)value;
但不确定此信息是否传递到传递到您的应用程序的 userActivity
。
编辑:
正如 user102008 指出的,您可以查看 Apple's Speakerbox example。
要解析联系人,您可以将此调用添加到您的意图处理程序
func resolveContacts(forStartAudioCall intent: INStartAudioCallIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void) {
// Your code here
}
编辑 2:
我还有很多东西要学 :( 这里有一个包含更多信息的 link:
当我在本机 phone 最近的通话中选择我的应用程序拨打的电话时 但是我只能得到id(EX:12345678),无法得到描述(EX:David)
native phone recents
info of the outgoing call
这是我在 AppDelegate.m
中的代码- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler NS_AVAILABLE_IOS(8_0)
{
INInteraction *interaction = userActivity.interaction;
INStartAudioCallIntent *startAudioCallIntent = (INStartAudioCallIntent *)interaction.intent;
INPerson *contact = startAudioCallIntent.contacts[0];
INPersonHandle *personHandle = contact.personHandle;
NSString *phoneNumber = personHandle.value;
}
我在 INPerson 对象中找不到任何关于描述(例如:David)的信息。
还有其他方法可以获取 phone 描述吗?
我认为你做不到。
配置 CXProvider 对象时,指定支持的句柄类型 (CXHandle.HandleType),例如:
providerConfiguration.supportedHandleTypes = [.phoneNumber]
When the telephony provider receives an incoming call or the user starts an outgoing call, the other caller is identified by a CXHandle object. For a caller identified by a phone number, the handle type is CXHandleTypePhoneNumber and the value is a sequence of digits. For a caller identified by an email address, the handle type is CXHandleTypeEmailAddress and the value is an email address. For a caller identified in any other way, the handle type is CXHandleTypeGeneric and the value typically follows some domain-specific format, such as a username, numeric ID, or URL.
您可以为出站调用添加通用 CXHandle:
- (instancetype)initWithType:(CXHandleType)type
value:(NSString *)value;
但不确定此信息是否传递到传递到您的应用程序的 userActivity
。
编辑: 正如 user102008 指出的,您可以查看 Apple's Speakerbox example。
要解析联系人,您可以将此调用添加到您的意图处理程序
func resolveContacts(forStartAudioCall intent: INStartAudioCallIntent, with completion: @escaping ([INPersonResolutionResult]) -> Void) {
// Your code here
}
编辑 2:
我还有很多东西要学 :( 这里有一个包含更多信息的 link: