CallKit - 最近通话中的通话记录不显示拨出电话的名称

CallKit - Call log in recent calls does not show name for outgoing call

我在 VOIP 应用程序中使用 CallKit。一切正常,除了在拨出电话后的最近通话列表中,它只显示号码,即使该号码已保存在电话簿中。 例如,电话簿中有一个名为 'John' 的联系人。现在,如果从应用程序拨出电话,在最近的日志中它只会显示号码。这就是我所做的。

NSUUID *callUUID = [NSUUID UUID];
CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:number];
CXStartCallAction *action = [[CXStartCallAction alloc] initWithCallUUID:callUUID handle:handle];
action.contactIdentifier = identifier; //identifier of that contact
[self.callController requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:completion];

问题是你在开始呼出时没有告诉供应商姓名,你可以通过添加performStartCallAction下一个代码来解决它:

CXCallUpdate *update = [[CXCallUpdate alloc] init];
[update setRemoteHandle:[[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:number]];
[update setLocalizedCallerName:name];

[provider reportCallWithUUID:uuid updated:update];

我用这段代码解决了同样的问题,现在它显示了名字。