Hello guys! I have a doubt about implementing back...
# multiplatform
e
Hello guys! I have a doubt about implementing background tasks in kmm. In android we've used workmanager so far. How can we implement background tasks in kmm apps?
p
Apple has a framework called BackgroundTask. You may find some similarities with Android Work Manager and create a wrapper layer around that
c
I actually just started working on a library to help with this. Currently only have a POC for in-process schedules and WorkManager, but iOS support is something I will be looking into as well. Still an early prototype, but feedback and/or contributions (especially for iOS) would be greatly appreciated! https://kotlinlang.slack.com/archives/C03GTEJ9Y3E/p1697648634102369 There are several KMP libraries I’ve seen that do “background tasks”, but from what I can tell, they all are just some form of “background threads” and don’t support persistent work like WorkManager.
🔥 2
a
BackgroundTask only works for iOS 13 and above though, so if you want to support earlier versions you'd want to use this.
p
Isn't iOS 13 a bit outdated? How many existing devices are running that OS version. It is around 4 years old and the average phone last no more than 2 years. Especially iOS, that has a better new device adoption rate than Android.
c
Yeah, looks like 97% of iPhones are running iOS 13 or higher (source). Unless you have very specific needs to run on very old phones, a requirement of iOS 13 seems perfectly reasonable
2
a
interesting, I've had to work with apps targeting iOS 12 before and it was a bit of a hassle that's why I thought of mentioning it.
p
Is a valid point, it depends on the project and the type of user you target obviously. Is a balance between ease of development using a newer API at the cost of losing a few users.
921 Views