Pushkit notification is not received if application is killed from background

2.3k views Asked by At

I am using PKPushkit for voip call notifications.

If my app is killed from background then I am unable to receive notification inside :

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType)

Though notification is working if app is in background. I have enabled following settings from project itself.

1) Inside capabilities , push notification is ON.

2) Background mode is on for:

a. App plays audio or streams audio/video using AirPlay.

b. App downloads content from the network.

c. App downloads content in response to push notifications.

d. App provides Voice over IP services.

Can any one help me to find out where I am missing ??

3

There are 3 answers

1
Hasya On

Possible your application is getting crashed when it is in killed state.

Check how to debug app in killed state.

enter image description here

https://github.com/hasyapanchasara/PushKit_SilentPushNotification

0
Alienpenguin On

On iOS 13 there is a new pushkit delegate method that should be called instead:

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void

it differs from the previous one (now deprecated) for the completion handler at the end of the prototype.

Failing to call the completion handler will then ban your app from receiving pushkit notification when in background or force-quit states. It still works while app is in foreground.

0
Vadim Zhuk On

In general the VoIP implementation contains the following steps:

  1. Adding a VoIP capability
  2. Register voip-Pushes:
    private func registerForVoIPPushes() {
        voipRegistry = PKPushRegistry(queue: nil)
        voipRegistry?.delegate = self
        voipRegistry?.desiredPushTypes = [.voIP]
    }
  1. Implementation of UNUserNotificationCenterDelegate
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void)
  1. Offcourse server side part implementation

  2. ! The most hidden and possible issue: Once the app got voIP notification and not reported it to CXProvider object it won't get notifications anymore until you reinstall it. So, be sure of reporting every voIP you get.