https://kotlinlang.org logo
#ios
Title
# ios
b

buszi0809

11/28/2023, 5:55 PM
Hi, I'm migrating my Android app to KMM In my app I have a task scheduled with AndroidX WorkManager that runs once a day at specific time, it runs a coroutine UseCase that should be injected by DI (I'm migrating to Koin) Now I'm looking for similar solution on iOS, I couldn't find a reliable stable library that would wrap WorkManager and iOS solution for easy use, so I did research myself, and it seems like I should use
BGTask
, but I don't really understand how I'm supposed to use it (and as far as I've read it does not support periodical work) When it comes to running it periodically I've read that it is possible to schedule next task when current is finished in order tu run it periodically, is it true? Has anyone implemented it in KMM and could share code samples, found a good article that would cover it, or found a repository that uses it?
a

Andrei Salavei

11/28/2023, 11:36 PM
Hi Kacper, Unfortunately, background jobs on iOS and Android are very different. Because of battery saving purposes, iOS does not provide any guarantee that scheduled task will be executed in time nor at all. Also, application behaviour is very different depending of is you device plugged in by cable or not. So yes, debugging background mode on ios - is a very tough thing. So, in general, there a re 3 ways how to schedule refreshes: • Background tasks, you mentioned • Downloading files in the background, if you're using request-specific refreshes. • Silent push, which gives you 30 seconds to do some job when an app receives push. The last one seems more stable and close to you needs, however you need push server that can periodically wake an app up by sending silent push notifications.
2 Views