Native cellular call fails on VoIP incoming call in iOS 13
Asked Answered
J

2

8

I have implemented CallKit for audio and video call with VoIP PushKit in iOS and it is working fine in iOS 12 and prior versions, and also it is working fine normally in iOS 13 and 13.1.

But it is failing in 2 scenarios:

1) Our App is in foreground state. When cellular call is running and VoIP push is received, then Call kit incoming call screen is showing for 5 - 10 seconds, and then both Cellular and VOIP calls are failing with Alert "Call Failed".

2) Our App is in Background or Killed state. When cellular call is running and VoIP push is received, then both Cellular and VOIP calls are failing with Alert "Call Failed". No incoming call UI is showing this time.

I am showing my code here:

- (void)registerAppForVOIPPush {

    PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
    pushRegistry.delegate = self;
    pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
}

Then Push delegates

#pragma mark PKPushRegistryDelegate ----

- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {

    NSString *newToken = [self hexadecimalStringFromData:credentials.token];
    //Make a note of this token to a server to send VOIP for a particular device
    NSLog(@"VOIP token ::: %@", newToken);
    _voipToken = newToken;
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type {
    //available(iOS, introduced: 8.0, deprecated: 11.0)
    [self pushRegistryDidReceivedPushWithPayload:payload forType:type withCompletionHandler:NULL];
}

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
    //available(iOS 11.0, *)
    [self pushRegistryDidReceivedPushWithPayload:payload forType:type withCompletionHandler:completion];
}

- (void)pushRegistryDidReceivedPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {

    //Call kit configration
    CXProviderConfiguration *providerConfig = [[CXProviderConfiguration alloc] initWithLocalizedName:@"my app Call"];
    providerConfig.supportsVideo = NO;
    providerConfig.maximumCallGroups = 1;
    providerConfig.maximumCallsPerCallGroup = 1;
    providerConfig.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInteger:CXHandleTypeGeneric], nil];
    providerConfig.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"IconMask"]);


    CXProvider *provider = [[CXProvider alloc] initWithConfiguration:providerConfig];
    [provider setDelegate:self queue:nil];

    //generate token
    NSUUID *callbackUUIDToken = [NSUUID UUID];

    //Display callkit

    NSString *uniqueIdentifier = @"Max test";
    CXCallUpdate *update = [[CXCallUpdate alloc] init];
    update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:uniqueIdentifier];
    update.supportsGrouping = FALSE;
    update.supportsUngrouping = FALSE;
    update.supportsHolding = FALSE;
    update.localizedCallerName = uniqueIdentifier;
    update.hasVideo = NO;
    [provider reportNewIncomingCallWithUUID:callbackUUIDToken update:update completion:^(NSError * _Nullable error) {
        NSLog(@"reportNewIncomingCallWithUUID error: %@",error);
    }];

    if (completion) {
        dispatch_async(dispatch_get_main_queue(), ^{
            completion();
        });
    }
}

I have implemented CXProvider delegate method perfectly

- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action{
    [action fulfill];
}

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action{
    [action fulfill];
}

and also managed other delegate methods to manage call and everything, and it is working perfectly in all conditions.

I have checked these two scenarios with other apps like Google Duo, Whatsapp and FaceTime and it's showing CallKit properly without failing, but in my app it is failing. I have no clue where it is failing.

So, I have this 2 stated issues for iOS 13 and later versions. Any help will be appreciated. Thanks.

Janel answered 26/9, 2019 at 12:41 Comment(0)
P
4

This is probably an iOS 13 bug and, if you haven't already done it, you should report it to Apple.

I think that the reason why apps like Whatapp (and the one I develop) are working, is that we build the app against the iOS 12 SDK. We do this because of the limitations of VoIP push notifications introduced in iOS 13. So, you can try to work around the issue—at least until April 2020—building against the iOS 12 SDK. Hopefully, Apple we'll soon fix this issue.

Phina answered 26/9, 2019 at 13:54 Comment(7)
Okay, I will check with that and also check if it affects UI changes to support iOS 13 or not.Janel
@Janel you got success?Tu
@RushangPrajapati, Yes it worked, and I got success in my defined problems.Janel
@Max, Hi Max, did you solve your issue, I have the same problem..Bereave
@Steven, issue is in latest iOS or xcode 11, So I have built app from xcode 10.2.1 and it works fine. We need to wait for newer version of iOS or xcode in which they fix this issue.Janel
@Steven, I have also verified this with 11.1 xcode and finally I have built with lower xcode version, Which works fine.Janel
@Janel Everything was good but now I am not able to receive VOIP after X times. Please look into my question and help me if you can. #63674048Tu
C
0

@Max I have faced the same issue that you faced in iOS version 13.0 to 13.2.0.

As many developers have reported this issue to Apple. The latest iOS version that released last week(iOS 13.2.2) has this bug resolved. So, now instead of building from older SDK, you can start working with latest SDK and xCode 11.2.1.

Castera answered 13/11, 2019 at 5:40 Comment(1)
Okay, Thanks for the update. I will check with latest Xcode.Janel

© 2022 - 2024 — McMap. All rights reserved.