Hi. Are there any convenient way for KMM to acces...
# multiplatform
a
Hi. Are there any convenient way for KMM to access network state for both Android and iOS? Looking to monitor connectivity lost/change. Considering that I am supposed to be a 3-rd party library.
b
Not convenient, but you can hook into native APIs via expect/actual
👆 1
j
ping the google dns or another one
s
At work, we tried to see if it was possible. But, it was not. Things like this that rely on hardware specific calls from the system APIs often times require you to go native. Android has it’s own stuff, iOS has it’s own stuff. If you want to create a common abstraction on both of those, you’ll still end up having to create the necessary platform specific calls to check if something is
online vs offline
k
Not convenient, but you can hook into native APIs via expect/actual
expect/actual, or some kind of interface if you want to stub that out for testing (but, yeah, you'll need to wrap native code)
t
https://github.com/splendo/kaluga/tree/develop/system#network does this, or you can check the source there
mind blown 3
y
Having written the Android side of this a number of times, I wish I'd known kaluga was available. Looks great.
a
@Tijl Looks like a GEM