CallKit - displaying outgoing call into recent call list

2.9k views Asked by At

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 :)

2

There are 2 answers

1
Rezwan On BEST ANSWER

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
Benjamin REIS On

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