Search code examples
iosobjective-cbackground-processapplication-state

Keep program running in background ios


I am working on an application which allows to send messages to another user.

If I press Home Button app goes first in background and then in suspended state so I don't receive any message unless I bring app back to the foreground.

How can I fix this to receive messages even if app is in background or suspended state? Solution is to avoid app to go suspended?

Some ideas please

Thanks and regards


Solution

  • For that you have to use Push notifications as they will wake your app when a notification is received (in your case a message is sent to your app). Do you have this implemented?

    Another Dirty way would be to keep a silent Music file playing when in background state thus the app nevel sleeps (unless terminated by user). Nut keep in mind that this trick wont let you publish your app to the app store!

    Hope this helps!