falconeta / capacitor-wifi-connect

15 stars 5 forks source link

Issue when connecting to WiFi on iOS with incorrect wifi password #21

Closed przemekRBC closed 5 months ago

przemekRBC commented 5 months ago

Hello,

I stumbled across strange behavior on iOS when connecting to WiFi using below method:

CapacitorWifiConnect.secureConnect({ ssid, password, saveNetwork: false })

The issue occurs when I provide incorrect password on first connection attempt to a network. Method wil return ConnectionState -4 (Wifi disabled). Even though if I provide correct password on any subsequent connection attempts I still receive same ConnectionState -4 status so I am practically unable to connect to this network anymore. To fix this, I need to go to WiFi Settings on iOS and manually connect to this network with correct password and this will probably reset some internal configuration. After this step I am able to connect to WiFi from my app using plugin.

This issue occurs both on 6.0.0 and 5.1.7 versions. I didn't test on different versions. I tested on Iphone 11 and Iphone XS Max. Both newest iOS version 17.4.1

Please let me know if you are able to reproduce this. If needed I will provide some minimal code which reproduces this issue.

Thank you for a development of this plugin!

falconeta commented 5 months ago

Hi @przemekRBC, this problem is an apple bug involving the joinOnce property used to save or not save the network (described here https://forums.developer.apple.com/forums/thread/700612). It has not been fixed yet and the only solution to fix it is to always save the network and remove it programmatically.

By the end of this week I will implement the fix that goes to remove the saveNetwork property, in the meantime you can try setting the property true

przemekRBC commented 5 months ago

Hi @falconeta. Thanks for investigating the issue. I confirm that setting "saveNetwork" to true solves the issue. I can successfully connect to a network on a second attempt if a first one had invalid password.