Amritansh
12/08/2020, 4:07 PMfun getConnectionType(): ConnectivityState {
val network = CTTelephonyNetworkInfo().currentRadioAccessTechnology
return if (network == CTRadioAccessTechnologyLTE || network == CTRadioAccessTechnologyWCDMA ||
network == CTRadioAccessTechnologyEdge || network == CTRadioAccessTechnologyGPRS ||
network == CTRadioAccessTechnologyCDMA1x
) {
ConnectivityState.Cellular(
carrier = CTTelephonyNetworkInfo()?.subscriberCellularProvider?.carrierName ?: ""
)
} else if (network == null) {
ConnectivityState.NoConnection
} else {
ConnectivityState.Wifi
}
}
I am not able to figure or device model since when I call UIDevice.currentDevice.model
it returns iPhone. I found this on stackoverflow but not sure how to write this code in KMM https://stackoverflow.com/a/11197770/4040394