Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Silent Push Notification Handling Behavior

I'm observing that when a silent push notification is sent to our app, is is started up in the background for 30 seconds before being suspended until the app is launched by the user. This causes data to persist from the silent push notification to the user app launch.

I couldn't find documentation on this behavior for silent push notifications, and was wondering if it's possible to have the app terminate after handling the silent push notification. Is there documentation on the general flow of silent push notifications as well?

I'm able to handle the edge cases if the app has to be suspended until user launch, but just want to confirm that this is the expected behavior before I go about handling it this way.

While you could call exit() on the main thread to terminate the app, I would say that is a drastic choice and a poor solution to your issue.

You would be better off managing your variables and their scope properly instead, handling the case of executing due to a silent push notification.

You can start by using beginBackgroundTask(expirationHandler:) and when the expiration handler gets called, you can reinitialize your variables ready for the next run.

Or to avoid all this you can limit the scope of the variables you use during execution for silent push notifications, if you want the user executions and push executions to be separate.

The exact best solution will depend on your app architecture, but terminating the app after every execution would be a shame.


Argun Tekant /  DTS Engineer / Core Technologies

Silent Push Notification Handling Behavior
 
 
Q