flutter-webrtc/callkeep

IOS app killed after receiving PKPushTypeVoIP notification

AbdurrehmanSubhani opened this issue · 4 comments

Hey!
I am trying to wake my application through a APNs VoIP notification to display an incoming WebRTC call however I just keep getting this error after receiving a voip notification:

Runner [42337:3797235] didReceiveIncomingPushWithPayloadpayload=PKPushTypeVoIP
Runner [42337:3707235] Do not use the 'alert' format for push type PKPushTypeVOIP.
Runner [42337:3707235] Apps receving VoIP pushes must post an incoming call via Callkit in the same run loop as pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:]withoutdelay.
Runner [42337:3707235] *** Assertion failure in -[PKPushRegistry _terminateAppIfThereAreUnhandledVoIPPushes], PKPushRegistry.m: 349
Runner [42337:37872351 *** Terminating app due to uncaught exception "NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push.'

Current flow of the application:

  1. Get Pushkit token through Callkeep's CallKeepPushKitToken() event
  2. Register this token with a 3rd party WebRTC framework
  3. Receive a voip push notification generated via the framework
  4. Upon receiving the notification im getting the error mentioned above^.

For callkeep setup im using the following code:
callKeep.setup(
_navigationService.router.navigatorKey.currentContext,
<String, dynamic>{
'ios': {
'appName': 'AppName',
},
'android': {
'alertTitle': 'Permissions required',
'alertDescription':
'This application needs to access your phone accounts',
'cancelButton': 'Cancel',
'okButton': 'ok',
'foregroundService': {
'channelId': 'com.company.my',
'channelName': 'Foreground service for my app',
'notificationTitle': 'My app is running on background',
'notificationIcon': 'Path to the resource icon of the notification',
},
},
},
backgroundMode: true,
);

Are there any additional steps required for acheiving background/terminated callkit call display using Callkeep package, any help would be much appreciated. Thanks!

P.S Callkeep works perfectly when the app is in foreground, this issue occurs when the app is in background/terminated state

Hi, I remember I had the same issue. The problem in my case was (if i remember correctly), that the initialisation of callkeep was not called. It has to be called relatively early in the startup phase of the app. I believe the process was shut down before the callkeep.setup was called, as iOS is requiring to react quickly (that is leading to the 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push.' log entry which basically just says the OS is shutting down the app now. ). Maybe that helps.

Hey @janhelwich, thanks for helping out!
Whilst trying to find a solution, I found this issue in this repo which seemed to be a similar issue and infact it was the cause of this issue:
#129 (comment)

I followed the temporary solution mentioned here by directing the Callkeep package to use the code from the forked repo and this fixed the issue, now the notification is received and the call is displayed as expected!
Solution link:
#129 (comment)

However, this solution or a better fix for this issue has yet to be added into the package repo so for anyone facing this issue just use the mentioned solution for now

This is definitely an annoying bug since PushKit is a native way to wake up an app.