Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS app killed after receiving PKPushTypeVoIP notification #162

Open
AbdurrehmanSubhani opened this issue Feb 17, 2023 · 4 comments
Open

Comments

@AbdurrehmanSubhani
Copy link

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!

@AbdurrehmanSubhani
Copy link
Author

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

@janhelwich
Copy link

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.

@AbdurrehmanSubhani
Copy link
Author

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

@sashker
Copy link

sashker commented Mar 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants