-
Notifications
You must be signed in to change notification settings - Fork 2
wifi vs cellular
github-actions[bot] edited this page Jun 2, 2026
·
1 revision
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import com.mobilebytelabs.kmptoolkit.networkmonitor.NetworkStatus
import com.mobilebytelabs.kmptoolkit.networkmonitor.compose.collectNetworkStatusAsState
@Composable
fun DataSaverNotice() {
val status: NetworkStatus by collectNetworkStatusAsState()
when (status) {
is NetworkStatus.Available -> {
val s = status as NetworkStatus.Available
if (s.transports.contains("cellular") && !s.transports.contains("wifi")) {
Text("On cellular — large downloads paused. Tap to override.")
}
}
is NetworkStatus.CaptivePortal -> Text("Captive portal detected — sign in to continue.")
is NetworkStatus.Unavailable -> Text("No network.")
}
}-
iOS / Android: transport detection requires
ACCESS_NETWORK_STATEon Android; iOS provides it via NWPath without entitlements. -
JS / wasmJs: browsers don't expose transport type —
transportsis alwayssetOf("unknown")when online; degrade gracefully. - Desktop: transport is "ethernet" on JVM Linux/Windows/macOS if a wired interface is the default route, else "wifi"; cellular is not detectable.
** Partials**
App Intents
Bubble
Clipboard
Cookbook
- Clipboard Copy Text
- Clipboard Read Text
- Consumer Anon Key Setup
- Crashlytics Attribution Per Library
- Ifonline Block
- Index
- Index
- Index
- Index
- Open Url Compose
- Pick And Share Image
- React To Offline
- Register Firebase Hooks
- Share Pdf Android
- Share Text
- Wifi Vs Cellular
Firebase Analytics
In App Update
Intent Launcher
Inter App Comms
Modules
- Cmp App Intents
- Cmp App Intents Compose
- Cmp Bubble
- Cmp Clipboard
- Cmp Deep Link
- Cmp Firebase Analytics
- Cmp In App Update
- Cmp Intent Launcher
- Cmp Intent Launcher Compose
- Cmp Library
- Cmp Network Monitor
- Cmp Network Monitor Compose
- Cmp Observe
- Cmp Observe Koin
- Cmp Open Url
- Cmp Pdf Generator
- Cmp Product Tickets
- Cmp Remote Config
- Cmp Share
- Cmp Share Compose
- Cmp Toast
Network Monitor
Open Url
Pdf Generator
Remote Config
Share
Toast
User Tickets
General