-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
findAndConnect should only return true upon connection success #4
Comments
Hi corymsmith, Android doesn’t provide a callback when you try to connect to a wifi network. You have to listen for connectivity changes to know if connection succeeded. You can use NetInfo from React Native Components to do it. If findAndConnect function returns false, you don't need to listen for this connectivity changes so you are not in range. |
I'm familiar with NetInfo, I guess it would be nice of this lib handled some of that but I completely understand why it currently doesn't :) |
If I have time maybe I'll submit a PR, otherwise we can probably close this. |
Yes, sure! It would be nice to have some help to improve it. The lib could handle all this logic and provide the desired callback. I leave this issue open, thanks! |
+1 for this |
My application needs to know the wifi password for another purpose. Let's say the user has the password already configured for this specific SSID. If the user has input the correct password then it will connect and netinfo will generate an event. This means there is no way to know if the password is correct or not. Edit: I've seen now that the code is supposed to delete that network This doesn't work, because, according to the documentation
This happens from Android 6.0 onwards |
based on this - it looks like one could emit an event or fulfill a promise (or both) when this broadcast receiver is invoked. |
There's a few methods that could be used for this, if you take a look at the fork of WifiWizard I have, you will see one PR I merged from original repo that checks in a for loop before resolving promise: |
@asCii88 That is the exact conclusion I've arrived to and this is completely stupid. Have you managed to find a way around it by any means? I've tried every combination of findAndConnect/netinfo/remove networks.. but with no luck. |
so I am trying to loop until the SSID is visible (think of it as a hardware device that has its own Hotspot). What would be the proper process to continue to try to connect to it? |
The comment and console logs you have here says it will return true if its in range, since the function is findAndConnect shouldn't this only return true once it actually connects? Otherwise whats the best way to know that its been connected?
The text was updated successfully, but these errors were encountered: