Wake up the app when you receive a notification in the background

Hello,

I am encountering an issue with maintaining socket connections in iOS applications that need to remain active while in background mode.

I am developing an application that requires maintaining an active socket connection in the background to receive real-time data. However, I've noticed that the socket connection is terminated as soon as the app enters background mode, which affects the intended functionality of my app.

I understand that there are restrictions on background activities in iOS to preserve battery life and system resources. However, I would like to know what approach Apple recommends for handling this type of requirement. Are there specific APIs or configurations I should consider to ensure the socket remains active in the background?

I would greatly appreciate any guidance or resources you could provide. I am eager to ensure that my app complies with Apple's guidelines and delivers the best possible experience for users.

Answered by Engineer in 823919022

First, you may want to read about iOS Background Execution Limits to understand what is possible or not, and why.

To specifically answer the question in your Subject: no, you cannot repeatedly wake people up the app when you receive a notification in the background. Background notifications can wake up an app at most 1-2 times an hour (for ~10 seconds execution time each), and that is if the device conditions are appropriate. If you were thinking of keeping the app awake by continually sending a notification every few seconds, that is not a solution which will work.

While it is possible for an app to keep a socket open IFF it is executing in the background continuously, that kind of capability is limited to certain types of apps, like navigation or audio playback apps. It is only permitted to use the APIs that will allow this for the express purpose of providing those features to the users, and not as a tool to keep an app active in the background for arbitrary reasons.

As stated in the App Review Guidelines

Section 2.5.4: Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc.


Argun Tekant /  DTS Engineer / Core Technologies

Accepted Answer

First, you may want to read about iOS Background Execution Limits to understand what is possible or not, and why.

To specifically answer the question in your Subject: no, you cannot repeatedly wake people up the app when you receive a notification in the background. Background notifications can wake up an app at most 1-2 times an hour (for ~10 seconds execution time each), and that is if the device conditions are appropriate. If you were thinking of keeping the app awake by continually sending a notification every few seconds, that is not a solution which will work.

While it is possible for an app to keep a socket open IFF it is executing in the background continuously, that kind of capability is limited to certain types of apps, like navigation or audio playback apps. It is only permitted to use the APIs that will allow this for the express purpose of providing those features to the users, and not as a tool to keep an app active in the background for arbitrary reasons.

As stated in the App Review Guidelines

Section 2.5.4: Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc.


Argun Tekant /  DTS Engineer / Core Technologies

Wake up the app when you receive a notification in the background
 
 
Q