how to check the internet availability in KMM (actual/expect)
ANDROID
actual class NetworkUtils actual constructor() {
actual fun isNetworkAvailable(): Boolean {
val connectivityManager =
application.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkInfo = connectivityManager.activeNetworkInfo
return networkInfo != null && networkInfo.isConnected
}
}
COMMON
expect class NetworkUtils() {
fun isNetworkAvailable(): Boolean
}
IOS
actual class NetworkUtils {
actual fun isNetworkAvailable(): Boolean {
//todo ?
}
}