Problem: The VoIP pushes are NOT received in background and killed state of app only in iOS 13 and above devices(Foreground mode works fine in these devices). Whereas it works fine in all 3 modes in devices with OS version less than 13.0.
Description We want to support audio video call in our app. So making use of VoIP pushes with Push-kit and Call kit frameworks.
I have gone through the documentation and followed all the steps to support VoIP pushes.
Capabilities enabled in info plist
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>location</string>
<string>remote-notification</string>
<string>voip</string>
</array>
Delegates are implemented like this. Using Callkit framework to report incoming call and to show call interface.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
dispatch_queue_t mainQueue = dispatch_get_main_queue();
self.pkPushRegistry = [[PKPushRegistry alloc] initWithQueue: mainQueue];
self.pkPushRegistry.delegate = self;
self.pkPushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
CXProviderConfiguration *config = [[CXProviderConfiguration alloc]
initWithLocalizedName:@"VoIP Service"];
config.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:
(int)CXHandleTypeGeneric], nil];
config.supportsVideo = true;
self.cxProvider = [[CXProvider alloc] initWithConfiguration:config];
[self.cxProvider setDelegate:self queue:nil];
return YES;
}
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials: (PKPushCredentials *)credentials forType:(NSString *)type {
// make use of the voip token to send push
}
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type withCompletionHandler:(nonnull void (^)(void))completion {
NSUUID *callUUID = [NSUUID UUID];
CXHandle *phoneNumber = [[CXHandle alloc] initWithType:CXHandleTypeGeneric
value:@"Test Sample VoIP"];
CXCallUpdate* callUpdate = [[CXCallUpdate alloc] init];
callUpdate.remoteHandle = phoneNumber;
[self.cxProvider reportNewIncomingCallWithUUID:callUUID update:callUpdate
completion:^(NSError * _Nullable error) {
if(error == nil) {
}
completion();
}];
}
I have created the voip certificate and sending the voip push properly from the server end.
After all these steps I am not receiving delegate call "didReceiveIncomingPushWithPayload" in background and killed modes.
Totally stuck at this stage. Please help me to solve this issue.