title: Native cellular call fails on VoIP incoming call in iOS 13
body: <p>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.</p>
  
  <p>But it is failing in 2 scenarios:</p>
  
  <p>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".</p>
  
  <p>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.</p>
  
  <p>I am showing my code here:</p>
  
  <pre><code>- (void)registerAppForVOIPPush {
  
      PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
      pushRegistry.delegate = self;
      pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
  }
  </code></pre>
  
  <p>Then Push delegates</p>
  
  <pre><code>#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();
          });
      }
  }
  </code></pre>
  
  <p>I have implemented CXProvider delegate method perfectly</p>
  
  <pre><code>- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action{
      [action fulfill];
  }
  
  - (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action{
      [action fulfill];
  }
  </code></pre>
  
  <p>and also managed other delegate methods to manage call and everything, and it is working perfectly in all conditions.</p>
  
  <p>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.</p>
  
  <p>So, I have this 2 stated issues for iOS 13 and later versions. Any help will be appreciated.
  Thanks.</p>