CallKit - displaying outgoing call into recent call list

末鹿安然 提交于 2019-12-24 10:56:38

问题


I am implementing a VoIP application, there I handled remote party for incoming call like

- (NSUUID *)reportIncomingCallWithContactIdentifier:(NSString *)identifier name:(NSString *)name telNumber:(NSString *)telnum completion:(ADCallKitManagerCompletion)completion {
    NSUUID *callUUID = [NSUUID UUID];

    CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
    //callUpdate.callerIdentifier = identifier;
    callUpdate.localizedCallerName = name;
    callUpdate.supportsHolding = NO;
    callUpdate.supportsUngrouping = NO;
    callUpdate.supportsGrouping = NO;
    callUpdate.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:telnum];
    [self.provider reportNewIncomingCallWithUUID:callUUID update:callUpdate completion:completion];
    return callUUID;
}

As a result the incoming call is showing in recent phone call list. But when I make an outgoing call, the number is not showing in the recent call list(system's phone app). Current implementation:

- (NSUUID *)reportOutgoingCallContactIdentifier:(NSString *)identifier destination:(NSString *)name telNumber:(NSString *)telnum completion:(ADCallKitManagerCompletion)completion {
    NSUUID *callUUID = [NSUUID UUID];
    //MARK::change in constructor, defined new handler
    CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:telnum];
    CXStartCallAction *action = [[CXStartCallAction alloc] initWithCallUUID:callUUID handle:handle];
    action.contactIdentifier = identifier;
    action.destination = name;

    [self.callController requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:^(NSError * _Nullable error) {
        NSLog(@"error %@",[error description]);
    }];
    return callUUID;
}

I need to know how I update remote handler for any outgoing call so that this will show in the remote phone call list.

Thank you :)


回答1:


For outgoing calls, updating the call using reportCallWithUUID right after performing requestTransaction does the job. but i'm not sure if it's the proper way as reportCallWithUUID is for updating any changes in an ongoing call.

- (NSUUID *)reportOutgoingCallContactIdentifier:(NSString *)identifier destination:(NSString *)name telNumber:(NSString *)telnum completion:(ADCallKitManagerCompletion)completion {
    NSUUID *callUUID = [NSUUID UUID];
    //MARK::change in constructor, defined new handler
    CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:telnum];
    CXStartCallAction *action = [[CXStartCallAction alloc] initWithCallUUID:callUUID handle:handle];
    action.contactIdentifier = identifier;
    action.destination = name;
    [self.callController requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:^(NSError * _Nullable error) {
        NSLog(@"error %@",[error description]);
    }];

    CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
    [callUpdate setRemoteHandle:[[CXHandle alloc] initWithType:CXHandleTypePhoneNumber value:telnum]];
    callUpdate.localizedCallerName = @"NAME";
    [_provider reportCallWithUUID:callUUID updated:callUpdate];

    return callUUID;
}



回答2:


You need to create a CXStartCallAction and request a CXTransaction with this action in order for your reportOutgoingCall to work.



来源:https://stackoverflow.com/questions/41481366/callkit-displaying-outgoing-call-into-recent-call-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!