Search code examples
iosionic-frameworkpush-notificationvoiphybrid

VoIP notifications in hybrid apps not working


Recently Apple changed its way of handling VoIP notifications. Now they force you to use CallKit in the same run loop in order not to throw your notification away. The trace I get is this one

Apps receving VoIP pushes must post an incoming call (via CallKit or IncomingCallNotifications) in the same run loop as  pushRegistry:didReceiveIncomingPushWithPayload:forType:[withCompletionHandler:] without delay.

When you get this warning three times, the system is "dropping your notifications on the floor".

The problem here is that I'm developing a hybrid VoIP app using the phonegap-plugin-push, and I'm afraid that the on notification event is not fast enough (or at least not the same run loop) for iOS.

Did anyone face this issue?

I've thought of changing to regular push notifications, but I can't find a way to make my app relaunch when it's killed and execute some code (launch CallKit, for example).

Edit: I'm trying this approach with push notifications and I already configured the background modes. I noticed that sending the "content-available" and some data, like "badge", or "alert" in the notification, the app is launched if it went to background recently. After 15 minutes in the background the push notification arrives but the app doesn't launch anymore

Thank you in advance.


Solution

  • I found a solution:

    Since iOS changed its policy about handling voip push notifications, it forces you to report a new incoming call when receiving the voip: https://forums.developer.apple.com/thread/117939

    This plugin does it: https://github.com/mattkhaw/cordova-plugin-callkit

    It merges two plugins (WebsiteBeaver/CordovaCall and Hitman666/cordova-ios-voip-push). It worked for me. I just had to remove the receiveCall from the javascript and tweak a little bit the plugin.

    The methods related to the voip notifications register are in the cordovaCall class, so it is pretty straightforward to work with.