Search code examples
iosvoippushkit

How much runtime does an app get when it receives a Pushkit Voip Push?


If an app is in the background or terminated and it receives a voip push then the OS will launch it and run it.

The documentation says:

"Your app is given runtime to process a push, even if your app is operating in the background."

Does anybody know how long this runtime is and if the app can find out how long there is remaining?

If an an app is in the foreground and moves to the background, then if it uses beginBackgroundTask() etc. it can get 30 seconds of execution time.

I've conducted experiments and found that if a silent push is delivered to the app when it is already in the background then the app can also use beginBackgroundTask() in that situation and it also get 30s seconds in which to execute and do something when it receives the push (and it can use UIApplication.shared.backgroundTimeRemaining to see how much time there is remaining.)

BUT if a Voip push is delivered instead of a silent push then beginBackgroundTask() functionality does not work (and of course therefore UIApplication.shared.backgroundTimeRemaining cannot be used to determine remaining execution time), however the app can run in the background and perform some activity (which is what the documentation quoted above says it can do).

So to repeat the question - is it documented by Apple how much time it does get to run when it receives the Voip push? Can the app find out how much time there is remaining? Or get some waring that execution time is about to expire?


Solution

  • is it documented by Apple how much time it does get to run when it receives the Voip push?

    No, There is no official documents available about how much time you have got, When received VoIP Push notification.

    As per my personal experience, You will extends time up to 45 Sec using long duration sound file if required.

    Can the app find out how much time there is remaining? Or get some Waring that execution time is about to expire?

    No, There is no official documents or do not available any delegate method to find how much time remaining.

    I have faced same issue, I was overcome above issue using multiple VoIP Push with different parameters. You can achieved it as below.

    As per my requirement, I have to display notification when user received new incoming call. If user not picked up call then i have to give new notification for missed call. I was achieved it as below.

    1) Generate local notification when received first VoIP Push. 
    
    2) Cancel already generated notification and generate new missed call notification for user.
    

    I am not sure, but you can also use timer if working.