Search code examples
iosvideocallkitincoming-call

Display video button in CallKit incoming call screen when call is video


I am using the following code to receive video calls. My application has audio and video call functionality and I am using linphone + CallKit.

- (void)config {
    CXProviderConfiguration *config = [[CXProviderConfiguration alloc]
                                       initWithLocalizedName:[NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleName"]];
    config.ringtoneSound = @"notes_of_the_optimistic.caf";

    config.supportsVideo = TRUE;

    config.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"callkit_logo"]);


    NSArray *ar = @[ [NSNumber numberWithInt:(int)CXHandleTypeGeneric] ];

    NSSet *handleTypes = [[NSSet alloc] initWithArray:ar];
    [config setSupportedHandleTypes:handleTypes];

    [config setMaximumCallGroups:2];
    [config setMaximumCallsPerCallGroup:1];


    self.provider = [[CXProvider alloc] initWithConfiguration:config];
    [self.provider setDelegate:self queue:dispatch_get_main_queue()];
}



- (void)reportIncomingCall:(LinphoneCall *) call withUUID:(NSUUID *)uuid handle:(NSString *)handle video:(BOOL)video
{
    CXCallUpdate *update = [[CXCallUpdate alloc] init];
    update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
    update.supportsDTMF = TRUE;
    update.supportsHolding = TRUE;
    update.supportsGrouping = TRUE;
    update.supportsUngrouping = TRUE;
    update.hasVideo = video;
    linphone_call_ref(call);
    // Report incoming call to system
    LOGD(@"CallKit: report new incoming call");

    [self.provider reportNewIncomingCallWithUUID:uuid
                                          update:update
                                      completion:^(NSError *error) {
                                          if (error) {
                                              LOGE(@"CallKit: cannot complete incoming call from [%@] caused by [%@]",handle,[error localizedDescription]);
                                              if (   [error code] == CXErrorCodeIncomingCallErrorFilteredByDoNotDisturb
                                                  || [error code] == CXErrorCodeIncomingCallErrorFilteredByBlockList) {
                                                  linphone_call_decline(call,LinphoneReasonBusy); /*to give a chance for other devices to answer*/
                                              } else {
                                                  linphone_call_decline(call,LinphoneReasonUnknown);
                                              }
                                          }
                                          linphone_call_unref(call);
                                      }];
}

Please see the attached screenshot of the incoming video call UI. It is displaying the same UI (buttons) for audio and video call. I want to display a video call button when the call is video. Is it possible using CallKit? If it's possible, what changes need to be made? Thanks in advance.

enter image description here


Solution

  • No, unfortunately there's no way to customize the CallKit incoming call UI. That's the reason why apps like WhatsApp are using push notifications to notify video calls, instead of relying on CallKit.