Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native cellular call fails on VoIP incoming call in iOS 13

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.

like image 722
Max Avatar asked Sep 26 '19 12:09

Max


People also ask

What is CallKit in iOS?

Apple's CallKit is a framework introduced with iOS 10. It gives users the ability to handle VoIP calls from third party apps, such as Skype, similar to how they would handle a system phone call.

How do I use CallKit in Swift?

Please follow the below steps for integrating the CallKit in your swift project. Create a swift project and name it as per your preference. Please add the background capabilities and check the in Voice per IP. Now create a button on the view controller for sending the call from your iOS app.

How to fix software and call failures in iPhone 13?

If you're facing any issue with the software and call failure in iPhone 13, you can use Dr.Fone - System Repair (iOS). It fixes all software problems with the iPhone/iPad and will take all your troubles away.

Why is my mobile data not available during a call?

Mobile data not available during call in … - Apple Community Looks like no one’s replied in a while. To start the conversation again, simply ask a new question. You will need to go to: Settings> Cellular >Enable LTE>Voice and Data. Make sure there is a check next to this category. Restart the device and test it out

What should I do if my iPhone won’t make calls?

Take out the SIM card. Look for damage. If you find any, consider getting a new SIM card. If you don’t find damage, reinsert the SIM card and try to make the call again. If you have another iPhone, you can try inserting the SIM card into that phone. Or, if you have another SIM card, you can try inserting it in the first iPhone.

Why do my calls keep dropping on my iPhone?

Open the Settings app and tap on Phone. Tap on Blocked Contacts. Make sure that the number you’re trying to call is not among the numbers you’ve blocked. A damaged SIM card could be the reason for failed or dropped calls on an iPhone. Check your SIM card for any damage or scratches, especially if you have been using it for a long time.


1 Answers

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.

like image 114
Marco Avatar answered Sep 20 '22 06:09

Marco