I am developing a chatting application. To enhance the message delivery experience, I was using VoIP push to deliver messages to the application in the background/killed state. This is just how whatsapp does this, I guess. It was working fine on devices with iOS version prior to 13.0. However, on iOS 13 devices the push is only coming in the foreground state. In the background state, I could not get callback in didReceiveIncomingPushWith
delegate method. I have gone through few online blogs where it's been written that apple restricted it to only use for the calling purposes now. One more thing that people proposed was that if the app is distributed over XCode 10 i.e, compiled with iOS 12 SDK then also it should work. However, It is not working in my case no matter what XCode I used. My objective is to deliver the messages to the users even when the application is killed/in background just like whatsapp. Any thoughts/guidance over this is highly appreciated. Thanks
I was facing your exact same issue; the problem for me was that on iOS 13 there is a new pushkit delegate method:
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. Documentation states that you must call the completion handler (even if void) to tell CallKit that the call has been handled. Failing to comply will then ban your app from receiving pushkit notification when in background or force-quit states. It still works while app is in foreground.
I solved adding to my app the following code:
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
NSLog("Got new callback incoming notification")
self.pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type)
DispatchQueue.main.async {
completion()
}
}
P.S. To clear the banned status (that is triggered after 2-3 compliancy failures in my tests) you need to completely delete the app from the device and start over.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With