Skip to content
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

Add Wifi SSID to the connection info #37

Closed
takosunil opened this issue Mar 26, 2019 · 10 comments
Closed

Add Wifi SSID to the connection info #37

takosunil opened this issue Mar 26, 2019 · 10 comments
Labels
enhancement New feature or request

Comments

@takosunil
Copy link

takosunil commented Mar 26, 2019

Describe the Feature

NetInfo.isConnected.addEventListener only works when wifi is turned on/off. I am looking to listen to an event when wifi switches from one network to another. Can anyone have some solutions or any workarounds? Thanks in advance.

Possible Implementations

NetInfo.isConnected.addEventListener("connectionSwitch", listener)
or
NetInfo.isConnected.addEventListener("wifiConnectionSwitch", listener)

@takosunil takosunil added the enhancement New feature or request label Mar 26, 2019
@matt-oakes
Copy link
Collaborator

Thanks for the request.

Just to confirm, are you looking for a way to listen for when the phone connects to a network with a different SSID?

If so, this might be something we can add to the ConnectionInfo which is returned from NetInfo. getConnectionInfo and NetInfo.addEventListener.

If you would like to contribute a PR to add this then that would be amazing.

Implementation details
For future reference, on iOS it is available through this function and on Android through this method.

@matt-oakes matt-oakes changed the title NetInfo.isConnected.addEventListener only works when wifi is turned on/off. I am looking to listen when wifi switches from one network to another. Add Wifi SSID to the connection info Apr 5, 2019
@FabioJfa
Copy link

FabioJfa commented Jun 2, 2019

I am also needing the WIFI SSID and IP to my APP. Is it being developed???

@matt-oakes
Copy link
Collaborator

@FabioJfa If there are any updates then they will be posted on the relevant issues. Contributions are always welcome

@petrbela
Copy link

A package with this functionality exists at https://github.com/pusherman/react-native-network-info. Maybe @pusherman might want to merge it here or at least provide guidance?

@gretzky
Copy link
Contributor

gretzky commented Jun 17, 2019

I have a private package for work that interfaces with most of the network info params (ssid, ip address, signal strength, etc.) but currently it's only for Android. I've opened #122 that adds 4 params to the details object: ssid, ip, signal strength, and carrier (for cellular). If anyone has done this for iOS and wants to add on, that'd be helpful! I don't primarily work in iOS right now so it would take me a bit longer to do.

@bondparkerbond
Copy link

I think we would need to request additional permissions and capabilities to get some of this information. On Android, we would need the location permission(coarse or fine) to get information on available SSID's and on iOS we would need Networking Capability Wifi Info. We may already be requesting some of this but if not we'd need to add this to the project.

@cltsang
Copy link

cltsang commented Aug 8, 2019

I'd love this feature integrated too, but CNCopyCurrentNetworkInfo is going to be deprecated in iOS 13 and there is no replacement to read SSID in sight.

So it might be a realistic expectation of Android, but not of iOS.

@matt-oakes
Copy link
Collaborator

Android support added in #122 🎉

@dawnmist
Copy link

dawnmist commented Oct 9, 2019

Apple have altered the use of CNCopyCurrentNetworkInfo in iOS 13 to require one of:

  • The app uses Core Location, and has the user’s authorization to use location information.
  • The app uses the NEHotspotConfiguration API to configure the current Wi-Fi network.
  • The app has active VPN configurations installed.

If none of those are present, it'll report a dummy SSID (iOS12-) or null (iOS13+) instead of the real one. It's not actually deprecated, just needs the app to request certain permissions in order to retrieve the real SSID, which could be left up to the react-native app to determine if they need that information and thus need to request permissions/capabilities for it.

That being the case, can the possibility of adding this for iOS too please be revisited?

@matt-oakes
Copy link
Collaborator

@dawnmist 👋 You're in luck! A PR for that is open here #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants