My app uses NEHotspotConfigurationManager
to connect itself to a certain device using a Wi-Fi. The device acts as an WPA2 access point. In older iOS versions (iOS 12 and lower) everything worked fine, but in iPadOS/iOS 13 the device is being disconnected after a while every single time. How to keep a connection on without storing NEHotspotConfiguration
permanently?
I suspect that it has something to do with a new feature - Multiple Windows (which is not supported by my app). The reason is that in my NEHotspotConfiguration
I set joinOnce
flag to true
(since the device's network should never be used outside the app). Apple's documentation states:
When joinOnce is set to true, the hotspot remains configured and connected only as long as the app that configured it is running in the foreground. The hotspot is disconnected and its configuration is removed when any of the following events occurs:
- The app stays in the background for more than 15 seconds.
- The device sleeps.
- The app crashes, quits, or is uninstalled.
- The app connects the device to a different Wi-Fi network.
Perhaps my app is falsely recognized as leaving a foreground.
Setting joinOnce
to false
makes the app keep the connection on, but it's not an acceptable solution, since my device doesn't provide an Internet connection and it must not be used outside the app.
Here is how I apply the hotspot configuration:
let hotspotConfiguration = NEHotspotConfiguration(ssid: self.ssid, passphrase: self.passphrase, isWEP: false)
hotspotConfiguration.joinOnce = true
NEHotspotConfigurationManager.shared.apply(hotspotConfiguration) { error in
// connection is successfully applied
// and about 15 seconds later it is lost.
}
I expect the connection to be kept on when joinOnce
flag is set to true
.
Apple appears to have fixed the issue in iOS 13.4 beta 2, it now works with joinOnce = true
as documented. Related discussion on Apple's forum
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With