Hi everyone, I need to create a KMM application fo...
# multiplatform
a
Hi everyone, I need to create a KMM application for both Android and iOS that can act as a local server to receive data from other local applications. Does anyone know if there’s a solution for this or any approach that could work?
f
look after ktor server
I never created a server inside a mobile app (with KMP) but you can try
🙌 1
a
I’ve already tested Ktor embeddedServer on Android, and it worked fine. However, since Ktor is intended for the JVM, it wasn’t possible to run it on iOS. But I see in the link you shared that it also supports Native without needing a virtual machine like the JVM, so I will test the latest version of Ktor. Thanks!
f
the server engine support iOS, you didn’t try?
K 1
Oh, you didn’t look at the documention 😄
a
i think that the native part was add recently
I’ll definitely give it a try with the latest version
👍 1
The limitation with running a server on an Android or iOS app was keeping it running in the background. On Android, I found a workaround, but I don’t think iOS will let me do that. xD
f
no way you can do that on iOS, it needs to be on foreground
there are some API hacks on iOS to keep your app alive, but it will be refused on Apple validation
1
a
And do you think iOS will allow running a small server in the foreground?
So I will try Ktor server, and I’ll keep you updated.
👀 1
f
the hack requires the usage of corelocation,
a
i get you.. thanks 👍
m
I think it’s important to understand what and how long running processes are supported on each platform target, foreground and background. Logging will tell the tale plus platform documentation (i.e. WorkManager for Android and the iOS equivalent)
1
a
Yeah .. On Android, it’s possible, but not on some versions where there are more restrictions (Like keeping a notification displayed ...), especially with the latest API SDKs. As for iOS, I don’t know as much.