I am working in VOIP application. I can receive voip push when app in background or foreground. But when an app is killed and device locked voip delegate **"didReceiveIncomingPushWithPayload"** method not called. Also, I am facing below crash **Killing VoIP app because it failed to post an incoming call in time** **VoIP push for app dropped on the floor** **Appdelegate didFinishLaunching** ``` - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. NSLog(@"didFinishLaunchingWithOptions"); // register remote notification [CCFMessageControl sharedInstance].calldelegate = [CallBackManager sharedInstance]; [CallBackManager sharedInstance].callPayloadDict = [[NSMutableArray alloc] init]; store = [[CNContactStore alloc] init]; [self registerForRemoteNotification]; if (application.applicationState == UIApplicationStateInactive) { if (![UserDefaultCoreDBManager isRealmFileExist]) { [self presentTouchID]; } } // Initialize Core Data Password [CoreDataSecurity storeDBEncryptionKeyInKeychain]; [CoreDBManager initialiseCoreData]; [CCFSharedMethod setUserDefaultBool:NO withKey:kMigrationInprogress]; //Check Realm Migration if ([UserDefaultCoreDBManager isRealmFileExist]) { // Realm DB initialize // to disable file protection on accessing realm file when device is locked [self setDefaultRealmPath]; [NotificationsCommonHandler migrationForRealm]; [self clearLocks]; // print Realm file path NSLog(@"filepath - %@",[[RLMRealmConfiguration defaultConfiguration] fileURL]); } // if (launchOptions[UIApplicationLaunchOptionsShortcutItemKey]) { UIApplicationShortcutItem *shortcutItem = launchOptions[UIApplicationLaunchOptionsShortcutItemKey]; self.launchedShortcutItem = shortcutItem; } // Check and Update Resource IP // [CCFLoginHelper getResourceIPAddressAndUpdate]; // Use Firebase library to configure APIs // Use crashlytics to trace crashes [FIRApp configure]; NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; [FIROptions defaultOptions].deepLinkURLScheme = bundleIdentifier; // // Firebase Force Update [CCFRemoteConfig.sharedManager Configure]; // To remove the notifications in Notification Center: [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications]; [[UNUserNotificationCenter currentNotificationCenter] removeAllPendingNotificationRequests]; // To set the badge (0 is no badge at all): [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]; if([UINavigationBar conformsToProtocol:@protocol(UIAppearanceContainer)]) { [UINavigationBar appearance].tintColor = [UIColor whiteColor]; } // set navigation bar background color [[UINavigationBar appearance] setBarTintColor: NEW_THEME_WHITE]; // navigation title color and font [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], NSForegroundColorAttributeName, FontRoboto, NSFontAttributeName, nil]]; [[NSUserDefaults standardUserDefaults] setValue:APP_NAME forKey:@"appName"]; [[UITabBar appearance] setTintColor:NEW_THEME_COLOR]; // Google Sign In // // [CoreDBManager stopAllOnProgressMedia]; //Checking Coredata migation if ([UserDefaultCoreDBManager isRealmFileExist]){ // // Check coredata migration CoreDataMigrationVC *coreDataMigrationVC = [[CoreDataMigrationVC alloc] initWithNibName:@"CoreDataMigrationVC" bundle:nil]; UIViewController *windowController = [[UINavigationController alloc]initWithRootViewController:coreDataMigrationVC]; self.window.rootViewController = windowController; self.window.backgroundColor=[UIColor whiteColor]; [self.window makeKeyAndVisible]; }else{ [self setUserBasedRootViewController]; } if (launchOptions[UIApplicationLaunchOptionsShortcutItemKey]) { UIApplicationShortcutItem *shortcutItem = launchOptions[UIApplicationLaunchOptionsShortcutItemKey]; self.launchedShortcutItem = shortcutItem; } if(![CCFSharedMethod getUserDefaultBoolForKey:@"firstLaunch"]){ [CCFSharedMethod setUserDefaultBool:YES withKey:@"firstLaunch"]; @try { NSData *imageData = [NSKeyedArchiver archivedDataWithRootObject:[UIImage imageNamed:@"chat bg"] requiringSecureCoding:NO error:nil]; [[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"wallpaperImage"]; } @catch (NSException *exception) { NSLog(@"Error = %@", exception.reason); } @finally { NSLog(@"finally"); } [CCFSharedMethod setUserDefaultBool:NO withKey:@"isSolidColor"]; } if ([[NSUserDefaults standardUserDefaults]valueForKey:KProfileBackgroundColor] == nil) { [[NSUserDefaults standardUserDefaults] setObject:[CCFCommonClass getrandomPlaceHolderColor] forKey:KProfileBackgroundColor]; } // IP Address Change Notifier [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateIpAddressOnNetworkChange) name:kReachabilityChangedNotification object:nil]; // Auto Download Settings if (![CCFCommonClass sharedInstance].chatSettingsArray.count) { [[CCFCommonClass sharedInstance] composeChatSettingsArray]; } // Exclude from backup // [self setupExcludeFromBackup]; return YES; } ``` **Resigter voip Notification** ``` - (void)registerVOIPNotifications { dispatch_queue_t mainQueue = dispatch_get_main_queue(); PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:mainQueue]; pushRegistry.delegate = self; pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; } ``` **didReceiveIncomingPushWithPayload delegate method** ``` - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion { NSLog(@"Push VOIP Received with Payload - %@",payload.dictionaryPayload); [VOIPManager.sharedInstance processPayload:payload.dictionaryPayload completion:^{ completion(); }]; } ``` **Process payload** ``` - (void)processPayload:(NSDictionary *)userInfo completion:(void (^)(void))callback { if (![CCFSharedMethod getUserDefaultBoolForKey:klLogin] || ![CCFSharedMethod ownJID].length) { NSLog(@"Push Status VOIP Not Logged IN"); return; } NSString *messageType = [userInfo valueForKey:@"type"]; /* ***** Call Processing ***** */ if ([messageType isEqualToString:kCallElement]) { CallModel *callModel = [[CallModel alloc]initWithDictionary:userInfo]; NSLog(@"Push Status VOIP Call MESSAGE RECEIVED"); if (@available(iOS 13.0, *)) { [self handleCallForiOS13ForCallModel:callModel completion:^{ callback(); }]; } else { [self handleCallForBelowiOSForCallModel:callModel]; } }else { // handle message received as VOIP notification [self handleMessageWithPayload:userInfo]; } } ``` **handleCallForiOS13ForCallModel** ``` - (void)handleCallForiOS13ForCallModel:(CallModel *)callModel completion:(void (^)(void))callback { { // If version is 13.0 or above NSLog(@"STEP CALL MESSAGE RECEIVED"); /* ***** Processing Call ***** */ if(!CallKitManager.sharedInstance.callUUID) { // New Call NSLog(@"Push Status VOIP Reporting call to CallKit"); CallKitManager.sharedInstance.delegate = CallBackManager.sharedInstance; [CallKitManager.sharedInstance reportIncomingCallWithPhoneNumber:callModel.callerName.length > 0 ? callModel.callerName : @"Unknown" hasVideo:[callModel.callType isEqualToString:klVideoCall] completion:^{ callback(); }]; }else { NSLog(@"Push Status VOIP already on MF call. So no need to inform CallKit. End / Engaged to this Caller - %@",callModel.socketID); } if([callModel.callStatus isEqualToString:kEndedStatus] && (![CallBackManager.sharedInstance.callID isEqualToString:callModel.callID] || !CallBackManager.sharedInstance.ownSocketId)) { NSLog(@"Push Status VOIP Call Invalid END Staus - %@",callModel.socketID); }else { NSLog(@"Push Status VOIP Call Inform to Callback Manager - %@",callModel.socketID); [CallBackManager.sharedInstance didReceiveIOS13VOIPCallMessageWithCallModel:callModel]; if ([callModel.callStatus isEqualToString:kEndedStatus]) { NSLog(@"Push Status VOIP Call CALL DEALLOC & ENDED for %@",callModel.socketID); }else { currentCall = callModel; } } /* ***** Remove Invalid message from notification bar ***** */ [NotificationsCommonHandler removeInvalidMessageForIDs:@[CCFInvalidMessageID,callModel.callID] onCompletion:nil]; } } ``` **Report Incoming Call** ``` - (void)reportIncomingCallWithPhoneNumber:(NSString *)phoneNumber hasVideo:(BOOL)hasVideo completion:(void (^)(void))callback { [self configureAudioSessionFortheCall]; self.update = [[CXCallUpdate alloc] init]; self.update.supportsHolding = YES; self.update.hasVideo = hasVideo; self.update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:phoneNumber]; if (self.callUUID == nil) { self.callUUID = [NSUUID new]; } _customCallModel->isCallConnected = NO; _customCallModel->isOutgoingCall = NO; [NotificationsCommonHandler saveCallKitCallInUserDefaults:_customCallModel]; NSLog(@"STEP CALLKIT REPORTING INCOMING CALL WITH SOCKETID %@",CallBackManager.sharedInstance.peerSocketId); [self.provider reportNewIncomingCallWithUUID:self.callUUID update:self.update completion:^(NSError * _Nullable error) { if (!error) { NSLog(@"STEP CALLKIT UI DISPLAYED FOR SOCKETID %@",CallBackManager.sharedInstance.peerSocketId); } else { if (self.delegate && [self.delegate respondsToSelector:@selector(callDidFailed)]) { [self.delegate callDidFailed]; } } callback(); }]; } ```