iOS leaves an accessory's no-internet Wi-Fi (NEHotspotConfiguration) for a saved network mid-session

We're building an iOS and Android app that transfers files to and from a device over a Wi-Fi network the device creates. That network has no internet access. The app gets the Wi-Fi credentials from the device (over Bluetooth, or from a QR code on its screen) and joins with NEHotspotConfiguration. Android works reliably. On iOS, partway through a session the phone leaves the device's network and joins a saved network that has internet, which breaks our connection to the device.

Setup:

  • iPhone 13 Pro, iOS 26.x
  • NEHotspotConfiguration(ssid:passphrase:isWEP: false) with joinOnce = false. With joinOnce = true, iOS usually stays on the current internet Wi-Fi and never joins the device's network.
  • WPA2. The device is at 192.168.4.1, and its DHCP server hands out the device as router and DNS.
  • Device traffic: NWConnection (TCP) with prohibitedInterfaceTypes = [.cellular]. Server traffic: a separate NWConnection with requiredInterfaceType = .cellular.
  • Wi-Fi Assist is off.

Example: we read an 8 MB file from the device (30 s, no problem), then post it to our server over cellular (93 s). During the post, the device connection carries only a small message every ~15 s. 28 s into the post, NWPathMonitor shows Wi-Fi drop out for 3 s, and when it returns the phone is on the our primary network. Occasionally iOS shows a prompt asking whether to stay connected without internet, but usually it switches without asking. We haven't seen it switch during the file read, while the device connection is busy.

Questions:

  1. Is there a supported way to keep iOS on a device's no-internet network for a whole session?
  2. Does traffic on the Wi-Fi interface (such as an active NWConnection) affect whether iOS switches away?
  3. Would a DHCP configuration without a router or DNS server change how iOS treats the network?
  4. Is joinOnce = false right for this, or can joinOnce = true join when the phone is already on an internet-capable Wi-Fi?
Answered by DTS Engineer in 907439022
Is joinOnce = false right for this

No. When you set joinOnce to false the system saves a network configuration for that network, much like it does when the user selects a network in Settings > Wi-Fi. That means that iOS will try to join that network like it would any other infrastructure Wi-Fi network. That’s not what you want here, because the network does not lead to the Internet. So iOS could potentially end up wasting time joining this network, only to find that it doesn’t connect to the Internet, and then leave it and trying the other saved Wi-Fi configurations.

So, yeah, you want joinOnce set to true. That creates an ephemeral association. iOS tries to join the network immediately but doesn’t save a configuration for it.

Also, you should check whether your accessory’s Wi-Fi hardware supports Wi-Fi Aware. If it does, you could use the Wi-Fi Aware framework to talk to it, which will be less disruptive.

Finally, I have a bunch of hints and tips for folks in your situation in the various posts hanging off Extra-ordinary Networking, most notably the Working with a Wi-Fi Accessory post.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is joinOnce = false right for this

No. When you set joinOnce to false the system saves a network configuration for that network, much like it does when the user selects a network in Settings > Wi-Fi. That means that iOS will try to join that network like it would any other infrastructure Wi-Fi network. That’s not what you want here, because the network does not lead to the Internet. So iOS could potentially end up wasting time joining this network, only to find that it doesn’t connect to the Internet, and then leave it and trying the other saved Wi-Fi configurations.

So, yeah, you want joinOnce set to true. That creates an ephemeral association. iOS tries to join the network immediately but doesn’t save a configuration for it.

Also, you should check whether your accessory’s Wi-Fi hardware supports Wi-Fi Aware. If it does, you could use the Wi-Fi Aware framework to talk to it, which will be less disruptive.

Finally, I have a bunch of hints and tips for folks in your situation in the various posts hanging off Extra-ordinary Networking, most notably the Working with a Wi-Fi Accessory post.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"