Swift Callkit Sometimes Can't Activate Loudspeaker After Received Call (Only Incoming Call)

Audio seems not work with CallKit when incoming call is answered

I found the error is about your code action.fulfill() is never called.

Based on document of Apple:

Calling this method sets the isComplete property value to true. Calling this method more than once or calling it after calling the fail() method has no effect.
You should only call this method from the implementation of a CXProviderDelegate method.

I hope you should call this method inside CXProviderDelegate. I have seen you implemented it but sadly that method is never called. I am sure this is the reason why your audio is not activated.

iOS Audio not working during call answered when phone is locked. WebRTC used for calling

I am able to resolve this issue.

Steps that I followed -

  • I checked the code related to WebRTC here

  • I added RTCAudioSession header file which is actually a private class of Webrtc. So every time I receive a call event from signaling, I enable RTCAudiosession and on end of the call, I disable it.

  • I have to render the incoming streams to a dummy view (Although it is not displayed when the call is going and the app is not yet open, but it is required to make audio working).

I hope this will help if someone is facing the same issue.

iOS 13 Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP callback

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:

  • You will only get 30 seconds to run.
  • These notifications must have a apns-priority of 5, which might cause them to be grouped and delivered in bursts, and even throttled or not delivered.
  • If the user force closes the app, it will completely ignore all silent notifications until the user opens the app again.


Related Topics



Leave a reply



Submit