VoIP with PushKit

Hi,


I'm working on a voip app using PushKit. The app should be able to receive voip push notifications in all possible app states (e.g. background, foreground, active, inactive). Using PushKit, I have to register the app with the background mode "voip" in the Info.plist - so far, so good. I still implemented the PFPushRegistryDelegate, which receives push credential updates or voip push notifications. This already works.


Here is my problem:

When the app is in suspended state and the screen is locked, the push notification will be received, but what do have to do now with that message? And what else can I do in the method didReceiveIncomingPushWithPayload?

I want to use the received voip push notification to start a file download or something else - something time consuming - and I want to do it in the background, so that the app can refresh itself in the background. But what happened is, that the app starts downloading the file in the background using background transfer service and stops working after about 4-5 seconds. It seems, that the app will be suspended by iOS after the push notification has been received.


What is the idea of the method didReceiveIncomingPushWithPayload?

What shall I do in this method, when time consuming things are forbidden?


I'm grateful for any help!

Hi,


Pushkit Notifications should not be used for long running background work.

Also they only should be used by VOIP apps(others will be declined).


If you have a VOIP app which can use pushkit there is a simple solution:

The notification should create a background task which downloads the file see https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html


If you don't have a VOIP app you have to work around that problem with silent notifications which are not guaranteed to arrive(also Pushkit is also not guaranteed with iOS 8).

So without VOIP priviliges you have to work around this problem to get the user to open the app so you can create a background task.

It is a VoIP application so it is authorized to use PushKit.

There is no problem to start a long background task.

However the background transfer service should work also. But this download method is supposed to be optimized for grouping download to save battery.


However when I tried PushKit, I faced many issues.

Especially the didReceiveIncomingPushWithPayload is not called any more after some times.

(Sometimes after many days working well)


Did it work for you ?

What I figured out is that not every voip push notification that has been sent by the server will be received by the iOS device. Sometimes it seems, that they got lost.

My app won't be put into the app store, so it is ok, that the app is marked to be a voip app without being a normal voip app.

I'm using the voip feature to be able to receive push notifications in all app states - including the suspended state. The notifications will be received even on the lock screen. But this worked sometimes and sometimes not, I cannot figured out why this happens. I found the following posting in the iOS dev forum archives (https://devforums.apple.com/thread/257354?start=0&tstart=0), but I haven't tested this solution yet. I agree with you, I faced many issues as well using PushKit.


My problem is still starting a background task, when a voip push notification arrives, the app is suspended and the lock screen is in front. In this case I register a new background task to download a file from a remote server. Therefore I'm using the NSUrlSessionDownloadDelegate - this works perfectly if the app is suspended and the device is unlocked. In locked mode the download starts but ended immeditely with the error "lost connection to background transfer service". I cannot find a solution for this error.

Accepted Answer

Pushkit seems to be buggy, a lot of developers are reporting that it stops working after some time so you should not use it yet.

Argh, ok, it seems you're right.

I'm wondering why apple publishes such a buggy library.

Anyway, I'll will use the "old" approach using SetKeepAliveTimeout.


Thanks!

The old approach requires you to have a server maintaining a connection if you want to be notified immediately.


Additionnaly the app won't be restarted if it has been killed.

VoIP with PushKit
 
 
Q