After upgrading to iOS beta 13 I\'ve noticed an unpleasant thing: my app crashes sometimes on incoming VoIP pushes.
In the crash report I see the following:
On this thread from apple forums, someone from apple staff explained this:
On iOS 13.0 and later, incoming Voice over IP calls must be reported when they are received and before the didReceiceIncomingPush() method finishes execution, using the CallKit framework, or the system will terminate your app.
Repeatedly failing to report calls may prevent your app from receiving any more incoming call notifications.
Basically, you can no longer use VoIP pushes for non VoIP messaging, and will need to use regular push notifications for those.
This was announced during the WWDC session "Advances in App Background Execution" https://developer.apple.com/videos/play/wwdc2019/707/
I've been searching for answers on how to adapt an app for this change, and what I could gather is the following:
Voip Pushes
When your app receive this kind of push, it will need to report a new incoming call using CallKit. Therefore, this kind of push will be exclusive for calls that use CallKit.
It's recommended that you set the notification's apns-expiration
to 0, so you won't receive a push and be forced to present a call screen for a call that already expired.
Push Notifications
Regular push notifications are another option. If your server has all the information you need to write the notification text, you can send notifications that won't even run your app in the background. If you need to modify the content of the notification before presenting it to the user, you can use a Notification Service app extension, and if you need your app to be woken up and execute something in background, you can send silent push notifications.
Notification Service App Extension
To use this, you must set your notification's mutable-content
to 1. This way, your extension will receive the notification before it is presented to the user, allowing you to change its content, with a 30 seconds time limit.
The cons are that your app will stay in the background, only your extension will be allowed to run. This might mean that you will need to share information and code between your app and the extension, either by using user defaults, keychain, or by sharing your entire database (which might not be a simple task if your app is not prepared for that).
Silent Push Notifications
To send silent push notifications, you must set your notification's content-available
to 1 and remove it's alert, badge and sound. This notification will wake up your app in the background, and call your app delegate's didReceiveRemoteNotification
.
The downsides are quite annoying for this option:
apns-priority
of 5, which might cause them to be grouped and delivered in bursts, and even throttled or not delivered.