Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Callkit: CXProvider resets immediately after starting

I am converting an existing VoIP application to Callkit. I have a lot of code in place but somehow when I initialize the CXProvider it will call providerDidBegin and immediately after that it will call providerDidReset. It doesn't give a reason for that. I cannot register one of my outgoing phone calls after that because my provider isn't active.

I have tried looking into certificates, settings and so on but basically I don't need more than I already have for my VoIP app it seems.

The call from CallKit calling the reset method is the following:

CallKit`__42-[CXProvider handleConnectionInterruption]_block_invoke:

When I dig deeper where it comes from, it's NSXPCConnection related. What is this connection and how do I need to set it up?

Of course there is no interruption in the connection.

This is how I initialize my Delegate:

- (id)init {
    self = [super init];

    self.configuration = [[ProviderConfiguration alloc] init];
    self.provider = [[CXProvider alloc] initWithConfiguration:self.configuration];

    [self.provider setDelegate:self queue:dispatch_get_main_queue()];

    return self;
}

This is what the configuration looks like:

- (instancetype)init {
    self = [super initWithLocalizedName:@"MyCompany"];

    self.supportsVideo = NO;
    self.maximumCallsPerCallGroup = 1;
    self.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:(int)CXHandleTypePhoneNumber], nil];
    self.maximumCallGroups = 1;
    self.maximumCallsPerCallGroup = 5;


    return self;
}

Both callbacks are implemented:

- (void)providerDidBegin:(CXProvider *)provider {
    NSLog(@"Begun");
}

- (void)providerDidReset:(CXProvider *)provider {
    NSLog(@"Reset");
}
like image 214
Lucas van Dongen Avatar asked Apr 19 '17 18:04

Lucas van Dongen


2 Answers

In my case the same issue was due to missing VOIP background mode in Info.plist file

<key>UIBackgroundModes</key>
<array>
    <string>audio</string>
    <string>voip</string>
</array>

XCode 9 doesn't allow to set this background mode using the Capabilities tab for some unknown reason.

like image 120
Vladimir Afinello Avatar answered Oct 04 '22 20:10

Vladimir Afinello


Make sure you're calling reportNewIncomingCallWithUUID:update:completion with a valid, nonnull, UUID. Apple's current implementation calls completion with no error but no call screen is shown

like image 34
Joe Tam Avatar answered Oct 04 '22 20:10

Joe Tam