Execute block of code when app in background

Hey Apple Developer Team,

what is best way to fetch chat messages (count arround 500+ messages) when app is in background or kill state by connecting to socket ?

In our app we do not have audio/video calling so can we use VOIP to awake app in background to connect to socket then fetch all the chat message?


my requirement is to awake the app periodically throughout day several time so that app can fetch latest messages from the server.

so what are the best ways you suggest?


thank you

Replies

What platform are you on? This seems more like a concurrency question, and there are different options on different platforms.


If you want it to run on macOS, I've found NSBackgroundActivityScheduler works wonders. The completion handler it uses can be trivially called from within an NSManagedObjectContext's perform method, too.

thanks for reply Saklad5

i am talking about ios platform.
could you please suggest something for ios?