I am trying to access connection type(cellular or ...
# ios
a
I am trying to access connection type(cellular or wifi), carrier name and device model using kotlin multiplatform on iOS. Any suggestions on how to approach this? I am an Android developer so I don't have much iOS experience My implementation so far
Copy code
fun 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