We are implementing PushKit/CallKit for audio video calls.
When the app starts, it immediately in AppDelegate-didFinishLaunchingWithOptions create the PKPushRegistry, set the delegate and ask for the token with desiredPushTypes and upload the token to our backend when PKPushCredentials are received. Then when didReceiveIncomingPushWith is called, it directly reports the call to CallKit.
That works fine on all devices, with the app in foreground, background, killed etc..
But on one slow device (iPhone 7, iOS 15.6.1) when the app has been killed for some time, the app do not receive anymore the token. Then at some point PushKit doesn't wake the app anymore, as CallKit was not notified.
According to the console logs by filtering callservicesd, the time between receiving the PushKit notification being received and delivering the token changes a lot, and then can timeout:
Successful call:
default 15:00:58.181051+0200 callservicesd Received incoming APS message from application with bundle identifier <private> and topic <private>
// ...
default 15:01:00.627903+0200 callservicesd Delivering token <private> to application <private>
So 2 seconds.
Failing call:
default 14:13:20.325371+0200 callservicesd Received incoming APS message from application with bundle identifier <private> and topic <private>
// ...
default 14:13:28.827702+0200 callservicesd Delivering token <private> to application <private>
// ...
default 14:13:32.325062+0200 callservicesd Invalidating process assertion for bundle ID <private> from timeout
8 seconds. Even if "callservicesd Delivering token" is written in the logs, the app do not receive it.
Then for the failing call, as didUpdate pushCredentials and didReceiveIncomingPushWith are not called, the app get killed:
default 14:13:32.326334+0200 runningboardd Invalidating assertion 33-134-19180 (target:[application<myAppId>:1363]) from originator [daemon<com.apple.telephonyutilities.callservicesd>:134]
default 14:13:32.393456+0200 runningboardd Received termination request from [daemon<com.apple.telephonyutilities.callservicesd>:134] on <RBSProcessPredicate <RBSProcessIdentityPredicate| application<myAppId>>> with context <RBSTerminateContext| domain:10 code:0xBAADCA11 explanation:<no explanation given> reportType:CrashLog maxTerminationResistance:Interactive>
error 14:13:32.404027+0200 callservicesd Killing VoIP app <private> because it failed to post an incoming call in time.
Is there any way to make sure that the token and the VoIP push will be delivered in time and not be killed by iOS, even on slow device?