Push Notification Sound and Notification Service Extension When App is Killed

Dear Apple Developer Support, I am currently developing an iOS application that uses push notifications with custom .caf audio and a Notification Service Extension. I have implemented the extension to download and play a dynamic sound file from a remote sound_url. It works well when the app is in the foreground or background. However, when the app is force-closed (swiped up from multitasking), the Notification Service Extension does not seem to run. As a result, the custom sound is not downloaded or played. I would like to confirm: Is it possible to trigger the Notification Service Extension when the app is killed? If not, what is the correct way to play a custom .caf sound when the app is terminated? Should I preload and save the .caf file in App Group storage and reference it by name in the sound field? Are there any best practices or limitations regarding push notification customization when the app is killed? I appreciate your help in clarifying this issue. Thank you very much! Best regards,

Phan Van Tung

The Notification Service Extension will indeed run even after the app has been force-closed. It runs in a separate process and is independent of the state of the main app.

does not seem to run

You will need to first establish whether it is not running at all, or just seems like that to you. You would need to first debug to find out what is going on with the extension.

If you are relying only on the fact that the sound you want is not playing, this could mean that the extension is failing to do it's work, rather than not run at all.

Extensions failing intermittently like this based on main app state could be caused by several factors, perhaps because it is depending on something that the main app is providing, or it is a coincidence.

In a process like yours, where you are depending on the availability and speed of a network connection along with a strict time limit of 30 seconds, it is possible that you might be running out of time, or your sound file is throwing you over the memory limit of 24MB.

But none of those will have any relation to the main app being force-closed, and would be coincidental.

In any case, you will need to do some debugging to find out what exactly is failing.

If the system is not launching the extension at all, you would see that in the Console app by watching what happens with your extension (search on the Bundle ID, when you send a notification.


Argun Tekant /  DTS Engineer / Core Technologies

Push Notification Sound and Notification Service Extension When App is Killed
 
 
Q