Closed bankiprudhvi closed 4 months ago
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.
Probably an issue regarding the new permission workflow NEARBY_WIFI_DEVICES for Android 13+ https://developer.android.com/guide/topics/connectivity/wifi-permissions
Is this repo still active ? Is there some mainteners ?
still facing lot of issues in Android 10,11,12,13 also one plus not working
Just try react-native-tethering and let me know
Просто попробуйте реагировать на родную привязку и дайте мне знать
Unresolved reference: STATUS_NETWORK_SUGGESTIONS_ERROR_RESTRICTED_BY_ADMIN
Just try react-native-tethering and let me know
Will this library work for ios?
Just try react-native-tethering and let me know
Will this library work for ios?
currently only works for Android but I look for a someone for IOS wrapper.
Just try react-native-tethering and let me know
Will this library work for ios?
currently only works for Android but I look for a someone for IOS wrapper.
I have tried this this package but when i run pod install i am getting this error
ERROR Invariant Violation: new NativeEventEmitter()
requires a non-null argument., js engine: hermes
Just try react-native-tethering and let me know
Will this library work for ios?
currently only works for Android but I look for a someone for IOS wrapper.
I have tried this this package but when i run pod install i am getting this error
ERROR Invariant Violation:
new NativeEventEmitter()
requires a non-null argument., js engine: hermes
That's expected. it only works for Android now please if you have any other questions you can open an issue in the lib's repo itself thank you.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.
Still issue not resolved.
Wifi connection success but not connected to wifi ... mobile -Google pixel 6a,One plus devices
is this repo people is in active mode ?
is this repo people is in active mode ?
Check out my lib react-native-tethering
Experiencing the same error on my device (Google Pixel 6a) as well. I've also raised an issue on react-native-tethering addressing this identical problem. You can find it here: react-native-tethering Issue #23.
I'm seeing the exact issue as well.
In my case, our code drops the existing SSID and connects to a new one for passing FWIW: I have tried adding all the permissions per other comments, including NEARBY_WIFI_DEVICES, and also cleartextTrafficPermitted in the network_security_config.xml file. I've confirmed that no matter how I structure the outbound package with network or axios, it just doesn't send the http text with Android 13. No packets are ever sent or received.
If you manually disconnect the original WiFi, it will send http over the new connection, even though getting the current SSID reports the new one.
I am experiencing the same issue on Android 13:
connectToProtectedSSID
it successfully passes successfully however the connection is not fulfilled
WifiManager.connectToProtectedSSID(ssid, password, false, false)
FYI: Foreground location permission is granted
I am experiencing the same issue on Android 13:
- If I never connected to that specific Wifi (WifiA)
- If I call
connectToProtectedSSID
it successfully passes successfully however the connection is not fulfilledWifiManager.connectToProtectedSSID(ssid, password, false, false)
FYI: Foreground location permission is granted
@Audrey-Ann Hi even if we connect to wifi from inside our app the connection would only be established temporarily with our application. you will see a similar message when you go to the Wi-Fi settings screen on Android.
I also faced this issue when I used WifiManager.connectToProtectedSSID(ssid, password, false, false).
@midhungopipk Thank you for your fast reply and explanation!
Do you find a solution or a workaround for it by any chance? :(
@midhungopipk Thank you for your fast reply and explanation!
Do you find a solution or a workaround for it by any chance? :(
No I just redirected the user to the wifi settings page directly from inside the app.
@midhungopipk I guess there's no better way :(
@JuanSeBestia would you recommend any workaround or explanation on why connecting to the Wi-Fi programatically using connectToProtectedSSID
doesn't work with Android 10+? Thanks in advance~
@JuanSeBestia is this library still being maintained?
Facing the same same with Pixel 7 and Android 14. Setup: React-Native v72.5 and the latest react-native-wifi-reborn v4.8.3
But it’s strange that what worked with RN v67.5 and RNFR v4.8.3
Is this only related to Pixel Phones? Has anyone found a solution?
p.s. @JuanSeBestia Tnx for the library!) Works great with other phones!
I have managed to get this working, but it's a little hard to pin down the exact issue.
Besides all the permissions mentioned above, if you're using the forceWifiUsageWithOptions, I found that this should only be called once before you use any connect functions. Near as I can tell, on Android13, every time you call forceWifi, it pops you back to the default network (wlan0). At least in my tests, Android 13 will create a second interface (wlan1) when you connect, then return to wlan0 if you execute the force afterwards.
It's a little confusing...
Do you know if this MR is solving the issue ?
https://github.com/JuanSeBestia/react-native-wifi-reborn/pull/319
About maintain, I tried to maintain a little, but I not work to much with RN at my work, sooo I'm open to receive new maintainers.
Always be free to open a new PR, if I see many approvals or LGTM I will approve and merge it also
Do you know if this MR is solving the issue ?
https://github.com/JuanSeBestia/react-native-wifi-reborn/pull/319
No, it is unrelated. The problem is on Android 13 the network cannot switch to wlan1 while the original wlan0 interface is still active and wlan1 has no Internet. However, if you forceUsageWithOptions first, then programmatically disconnect/shut down wlan0, then try to connectToProtectedSSID you can get it to work if you wait long enough. See my details posted previously.
Hi @jayadelson is noInternet: Boolean
the only option you used? And if it's okay for you to share, can you lay out the steps that allowed you to connect to the network? (which method you called first and how you handle the disconnect/connect)
Thanks in advance!
@JuanSeBestia is there any other options aside from noInternet
available for wifi network does not have internet connectivity
and do you have the official Android documentation as well by any chance? Thanks!
Hi @jayadelson is
noInternet: Boolean
the only option you used? And if it's okay for you to share, can you lay out the steps that allowed you to connect to the network? (which method you called first and how you handle the disconnect/connect)Thanks in advance!
@Audrey-Ann First, I make sure my permissions are spot on with AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COURSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:required="true"
android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:required="true"
android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission
android:required="true"
android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission
android:required="true"
android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES"
android:usesPermissionFlags="neverForLocation" />
<application
android:networkSecurityConfig="@xml/network_security_config"
</application>
and my network_security_config. Note that I replace A.B.C.D with the IP address of the device I'm connecting to over the new connection, as I intend on sending clear text info to that device:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<!-- Without localhost setting, you won't be able to connect metro with app. -->
<domain includeSubdomains="true">127.0.0.1</domain>
<!-- For a device, [A.B.C.D] is the address of the the device's network interface -->
<domain includeSubdomains="true">[A.B.C.D]</domain>
</domain-config>
</network-security-config>
I then go through a series of permissions checks when the app opens or tries to render the component that will be doing the WiFi activity. Since this is Android 13, it requires the NEARBY_WIFI_DEVICES check which hadn't been required previously, along with the other permissions above. Once those permissions have cleared and check back as granted, I grab the current SSID, and perform a WiFi scan for the newDeviceSSID. Then I begin to run through the process of changing the network in this order. Don't use this code verbatim, it's heavily edited, but gives you the general idea:
if (Platform.OS == 'android') {
try {
if (WifiManager.forceWifiUsageWithOptions && Platform.Version >= 28) {
await WifiManager.forceWifiUsageWithOptions(true, {noInternet: true});
}
if (currentWifi.current != newDeviceSSID) {
try {
await WifiManager.isRemoveWifiNetwork(currentWifi.current);
// Wait for the device to disconnect from the current network
await new Promise(resolve => setTimeout(resolve, 5000));
} catch(disconnectError) {
console.log("Error while disconnecting from WiFi:", disconnectError)
}
}
const data = await WifiManager.connectToProtectedSSID(
newDeviceSSID,
password,
false,
false,
);
} catch (error) {
console.log(`Android failed to connect to ${newDeviceSSID}.`)
console.log("Error:", error.message);
}
}
} else {
[iOS]
}
}
Essentially, I first execute the forceWifiUsageWithOptions, then disconnect the current wlan0, then connect the new network, in that order. What isn't in this code is my tracking of the connection status. If the function completes I set the noInternet to be false and restore the original connection.
@jayadelson Thank you so much for your explanation, you're amazing.
It's funny cause I already had the same kind of flow but I will try integrating the isRemoveWifiNetwork
and forceWifiUsageWithOptions
. Also add that new permission.. NEARBY_WIFI_DEVICES
.
I was using the disconnect method before connecting every time, is there a reason to use isRemoveWifiNetwork
instead? Is it because it not only removes the connection but also the configurations as well?
FYI I will be making my changes on my side today and let you (guys) know :) !
Also, @JuanSeBestia do you think you could update the README.md
file accordingly when we can safely make Android 13 work? :)
Woot woot 💪🏼
I was using the disconnect method before connecting every time, is there a reason to use
isRemoveWifiNetwork
instead? Is it because it not only removes the connection but also the configurations as well?
You're very welcome. The isRemoveWifiNetwork was because I could tell as long as the network existed, the routing went out that interface. I think in my flailing around trying to get something working I switched to that and had better success.
I also experience this problem, I tested with several devices.
Device | Android version | Does it work? |
---|---|---|
Samsung S21 | 13 | ✅ |
Google Pixel 6 | 14 | ❌ |
Samsung S9 | 10 | ✅ |
Oneplus 6T | 11 | ✅ |
Motorola Moto G 5G Plus | 11 | ✅ |
On the Pixel 6 (with Android 14) it doesn't work; unfortunately I don't have an other Google Pixel device, but it seems like the issue is related to PIxel devices, since the OP mentioned?
isRemoveWifiNetwork
isn't a viable option for the use case.forceWifiUsageWithOptions
both before and after the connect
callNEARBY_WIFI_DEVICES
permission
- Using
isRemoveWifiNetwork
isn't a viable option for the use case.- I also tested with no other known Wifi networks nearby and the problem still occurs.
- I did use
forceWifiUsageWithOptions
both before and after theconnect
call- I also added the
NEARBY_WIFI_DEVICES
permission
Two questions: Are you disconnecting first before performing the network switch? Also, I have found if you use forceWifiUsageWithOptions after you run the connect* process it will switch back to the original network before your task is complete. Have you tried removing the forceWiFi function after the connect call?
Placing the call before connecting does seem to fix the issue I was having on Android 13/14 Pixel 7. I did not need to call isRemoveWifiNetwork or disconnect methods. Testing still passes on a Motorola Android 11 and a Nokia Android 10. No other devices to test on.
Placing the call before connecting does seem to fix the issue I was having on Android 13/14 Pixel 7. I did not need to call isRemoveWifiNetwork or disconnect methods. Testing still passes on a Motorola Android 11 and a Nokia Android 10. No other devices to test on.
That's great to hear. Glad this is clearing up for folks. It would be great if @JuanSeBestia could include some information about the usage best practices in the documentation, or change the module to somehow not switch to WLAN0 on making the call.
- Using
isRemoveWifiNetwork
isn't a viable option for the use case.- I also tested with no other known Wifi networks nearby and the problem still occurs.
- I did use
forceWifiUsageWithOptions
both before and after theconnect
call- I also added the
NEARBY_WIFI_DEVICES
permissionTwo questions: Are you disconnecting first before performing the network switch? Also, I have found if you use forceWifiUsageWithOptions after you run the connect* process it will switch back to the original network before your task is complete. Have you tried removing the forceWiFi function after the connect call?
Hi @jayadelson, thanks for your reply.
Yes, I already was disconnected from other networks (no WiFi in range, mobile data turned off)
I also placed forceWifiUsageWithOptions
before the connect
-call, but I'm not sure if I removed the forceWifiUsageWithOptions
-call after connecting. I hope I'll have time to investigate this Friday, otherwise I'll get back to this in the week of november 20 - 24.
It is unconfirmed if placing the forceWifiUsageWithOptions before the call still creates the effect of its purpose. If I simply comment out the method, then the Pixel 7 and other two devices will also still work for me.
So, I'm curious if placing it above it creates the same effect as not using forceWifiUsageWithOptions . If so, it may break other devices that need it. Can anyone confirm that it maintains the desired behavior?
Hi,
I have examined this issue using the sample project from https://github.com/JuanSeBestia/react-native-wifi-reborn.
I conducted the tests on a Google Pixel 6 running Android 14 and a Samsung S21 operating on Android 13. When attempting to connect to an Iot network:
On Android 14, Wifi Reborn indicates a successful connection; however, the quick settings reveal that it remains connected to the "Current" network. On Android 13, the change to the new Wi-Fi network is visibly reflected in the navigation bar and you can see it disconnecting and connecting to the new network, and the quick settings confirm the connection to the new network.
It is unconfirmed if placing the forceWifiUsageWithOptions before the call still creates the effect of its purpose. If I simply comment out the method, then the Pixel 7 and other two devices will also still work for me.
So, I'm curious if placing it above it creates the same effect as not using forceWifiUsageWithOptions . If so, it may break other devices that need it.
Can anyone confirm that it maintains the desired behavior?
I can confirm that if I use the force method before the connect call, Android 13 will connect to a network that has no Internet connectivity (local only).
I've had the chance to test this on a Samsung S23 running Android 14, and it works well on that device. I'm looking to get my hands on another Google Pixel to check, but from what I can tell at the moment and this thread, this issue seems to be specific to Google Pixel phones.
jayadelson, gitknul I don't know at the moment what I put, but the repo is always open to receive more MR, feel free to add a MR with the changes in the README.md or more .md files to helps another guys in the future :)
Just try react-native-tethering and let me know
Will this library work for ios?
currently only works for Android but I look for a someone for IOS wrapper.
I have tried this this package but when i run pod install i am getting this error
ERROR Invariant Violation:
new NativeEventEmitter()
requires a non-null argument., js engine: hermes
This is also my issue when I build and run in IOS
Just try react-native-tethering and let me know
Will this library work for ios?
currently only works for Android but I look for a someone for IOS wrapper.
I have tried this this package but when i run pod install i am getting this error ERROR Invariant Violation:
new NativeEventEmitter()
requires a non-null argument., js engine: hermesThat's expected. it only works for Android now please if you have any other questions you can open an issue in the lib's repo itself thank you.
Hi, how can I avoid this error when I am testing/developing/runing in IOS ?
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.
I would say that the library just needs some clarification in the docs over the process I described here:
https://github.com/JuanSeBestia/react-native-wifi-reborn/issues/303#issuecomment-1786089001
I'm not the guy to document this as I don't have enough understanding of the underlying reasons why it works.
Just chiming in..... I got it to work on Android 14 by doing: await WifiManager.forceWifiUsageWithOptions(true, { noInternet: true }) await WifiManager.disconnect(); 5 second timeout WifiManager.connectToProtectedSSID then crucially removing my forceWifiUsageWithOptions that I had been sending AFTER connection.
Hope it helps someone.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.
Not fixed
Any updates please ? It doesn’t work ! I'm connected but not access to internet on Samsung S21 Android 14
Wifi connection success but not connected to wifi ... mobile -Google pixel 6a