Using Wi-Fi in Mobile Apps
Detect connection state, scan for networks, configure devices and even use Wi-Fi positioning — within the strict limits of modern OS privacy rules.
Wi-Fi is the workhorse of mobile data, but the APIs around it have been heavily locked down — for good reason. You can no longer freely scan SSIDs or grab the user's MAC address. What you *can* do is detect connectivity, suggest networks, configure smart-home devices and (on Android) measure precise distance using Wi-Fi RTT.
Key Takeaways
- iOS lets you read SSID only when you have location permission and the user is in your app.
- Android 11+ requires the Companion Device or Network Suggestion APIs for almost everything beyond connectivity state.
- For IoT onboarding, use NEHotspotConfiguration (iOS) and WifiNetworkSpecifier (Android).
- Wi-Fi RTT is a niche, Android-only API for precise indoor positioning.
Wi-Fi APIs at a Glance
What It Is & How It Works
What it is. A radio that joins 802.11 access points. The OS exposes connectivity state, network suggestion APIs for joining new networks, and (on Android) scanning + RTT for advanced apps.
How it works. Use the connectivity APIs (NetInfo, NWPathMonitor, ConnectivityManager) for state. For onboarding, suggest a network so the OS shows the join sheet. For RTT, use WifiRttManager.
Units & signal. SSID, BSSID (MAC), signal strength (RSSI in dBm), frequency band, throughput estimate.
What You Can Build With It
Connection awareness
Toggle features when on Wi-Fi vs cellular, or when offline.
Example: A music app showing offline-only library when not connected.
IoT onboarding
Help the user join a smart-home device's temporary AP, then push them back to home Wi-Fi.
Example: A bulb manufacturer's setup app.
Network suggestion (no UI)
Save corporate or partner networks so they auto-join in the future.
Example: An enterprise app pre-configuring office Wi-Fi.
Indoor positioning (Android)
Use Wi-Fi RTT round-trip time to measure distance to known APs.
Example: A museum guide locating visitors within 1-2 m.
Permissions & Setup
Reading SSID requires location permission on both platforms; configuring networks requires the relevant entitlement (iOS) or NEARBY_WIFI_DEVICES (Android 13+).
iOS · Info.plist
NSLocationWhenInUseUsageDescription (for SSID)com.apple.developer.networking.HotspotConfiguration entitlement
Android · AndroidManifest.xml
android.permission.ACCESS_NETWORK_STATEandroid.permission.ACCESS_WIFI_STATEandroid.permission.CHANGE_WIFI_STATEandroid.permission.ACCESS_FINE_LOCATION (for SSID/scan)android.permission.NEARBY_WIFI_DEVICES (Android 13+)
Code Examples
Setup
- Expo: `npx expo install expo-network @react-native-community/netinfo`
- iOS: enable Hotspot Configuration entitlement and request Location When In Use
- Android: declare Wi-Fi + location permissions and request at runtime
import * as Network from 'expo-network';
import NetInfo from '@react-native-community/netinfo';
export async function inspectWifi() {
const { type, isConnected } = await Network.getNetworkStateAsync();
const ip = await Network.getIpAddressAsync();
const detail = await NetInfo.fetch();
return {
type,
isConnected,
ip,
ssid: detail.type === 'wifi' ? detail.details?.ssid : null,
rssi: detail.type === 'wifi' ? detail.details?.strength : null,
};
}Tip: With Newly, you describe the feature you want and the AI agent wires up the sensor, permissions, and UI for you. Try it free.
Best Practices
Use Network Suggestion / Hotspot Configuration for joining networks
Both APIs avoid the user re-entering passwords on every visit and respect their default Wi-Fi UI.
Always pair SSID reads with location prompts
Both platforms refuse to return SSID otherwise — and surfacing the rationale keeps users on side.
Detect captive portals explicitly
Both OSes expose a captive portal probe; checking it before assuming "internet" prevents broken UX in coffee shops.
Use Wi-Fi RTT only where it pays off
RTT requires both phone and AP support; a fallback to GPS / BLE beacons is essential.
Common Pitfalls
Trying to scan all SSIDs on iOS
There is no public API for it.
Mitigation: Use NEHotspotConfiguration to join a known network instead.
Forgetting NEARBY_WIFI_DEVICES on Android 13+
Calls return empty results without it.
Mitigation: Add the permission and request at runtime.
Hard-coding home/office SSID strings
SSIDs are user-modifiable and locale-dependent.
Mitigation: Let users choose / save the network during onboarding.
When To Use It (And When Not To)
Good fit
- Connectivity-aware UI
- IoT device onboarding flows
- Pre-configuring partner / enterprise networks
- Indoor positioning where Wi-Fi RTT is available
Look elsewhere if…
- Background SSID scanning for analytics
- MAC-based device identification
- Cross-platform Wi-Fi positioning (use a different stack)
- Anything assuming free, anonymous radio scanning
Frequently Asked Questions
Why does my SSID come back as "<unknown>"?
You're missing location permission, or your app isn't in the foreground.
Can I make the user join a Wi-Fi network silently?
No — both OSes always show a confirmation sheet, even when using suggestion APIs.
What is Wi-Fi RTT?
Round-Trip-Time ranging — an Android-only feature that measures distance to compatible APs to within a few metres.
Can I read the MAC address of nearby devices?
Both OSes return randomised or hidden MACs to non-system apps. Don't rely on MAC for identification.
Build with the Wi-Fi on Newly
Ship a wi-fi-powered feature this week
Newly turns a description like “use the wi-fi to connection awareness” into a real React Native app — permissions, native modules and UI included. Full source code is yours, and you can publish to the App Store and Google Play directly from the dashboard.
Want a deeper dive on the underlying APIs? See Expo Sensors, Apple Core Motion and Android sensor framework.
