Giter Site home page Giter Site logo

react-native-android-wifi's People

Contributors

adhambadr avatar alexanderkosianchuk avatar bondparkerbond avatar btav avatar devstepbcn avatar gigby avatar gsinovsky avatar hjames9 avatar iamcc avatar leecrossley avatar mojabyte avatar parthbarot-botreeconsulting avatar sharnik avatar sina-s avatar tuaminen avatar ymrdf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-android-wifi's Issues

wifi.reScanAndLoadWifiList does not update on Android 8.0.0

Hi, I am trying to use reScanAndLoadWifiList on Android 8.0.0 .
React-Native version is 0.57.5 and the phone is Samsung Galaxy S7 edge.

I was hoping reScanAndLoadWifiList was going to refresh the list every time I called, but so far it behaves exactly like wifi.loadWifiList - it loads the wifilist once and then returns exactly the same list every time it is called again.

I am using your sample code with output via ToastAndroid on refresh of the screen.

wifi.reScanAndLoadWifiList((wifiStringList) => {
ToastAndroid.show(wifiStringList,ToastAndroid.SHORT);
var wifiArray = JSON.parse(wifiStringList);
console.log('Detected wifi networks - ',wifiArray);
},(error)=>{
console.log(error);
});

Regards

Not connecting with open WIFI

I am new to react native & android. I am checking your example. When i connect to the secured wifi it is connecting and returning found true, that is cool. But when i connect to open network it not no established the connection, but it returning found true I am using Android 7.1.1.

If it is not a bug can anyone guide me to fix this?

[Bug] Both loadWifiList() and reScanAndLoadWifiList() return empty list

@devstepbcn ,
Can you please check why both loadWifiList() and reScanAndLoadWifiList() return empty list?
It happen in both AVD and Physical devices.

Here are some info:
"react": "16.0.0-alpha.12",
"react-native": "0.48.4",
"react-native-android-wifi": "0.0.31",

Code:

Wifi.reScanAndLoadWifiList((wifiStringList) => {
	console.log('Wifi list: ', wifiStringList);

	var networks = JSON.parse(wifiStringList);

	this.setState({
		loading: false,
		wifi: {
			...this.state.wifi,
			scanning: false,
			networks: networks
		}
	});
},
(error) => {
	console.log(error);
});

Log:
07-04 22:39:09.982 4560 4645 I ReactNativeJS: 'Wifi list: ', '[]'

findAndConnect not working on Android 8.0

RN version: 0.54
Device: Huawei P10, Android 8.0

Greetings!

Module works perfectly in past 3 month, but today I'm updated Android version from 7.1.1 to 8.0 on my phone and I realized, that it's not connecting.

I tried out with example too, but the result is the same.
On other phones with 7.1.1 Android it's working.

Package is overweighted

Hi,

After a npm install of your package, the directory size is 118M, mostly due to Example directory, embedding build stuff

du node_modules/react-native-android-wifi/Examples/Example/android/app/ -h -d 1
88K	node_modules/react-native-android-wifi/Examples/Example/android/app/src
59M	node_modules/react-native-android-wifi/Examples/Example/android/app/build
60M	node_modules/react-native-android-wifi/Examples/Example/android/app/

You should clean that, it's totally useless and horrible for users :)

Appears to be broken on Android 8.1

Hi There!

Thanks for all of your hard work - I really appreciate it! I did my best to create an exact bug report! Hope this helps!

1. I've just booted the ExampleAPI25 app on an Android Emulator running Android 8.1.

I'm seeing some strange behavior:

Weird behavior 1:

  • Ensure network is "Forgotten" from the Android Settings
  • I click "Get connection status" and it says "You're not connected :("
  • I click Current SSID and it says "AndroidWifi" (shouldn't this be null as I'm not connected)? ๐Ÿ‘Ž

Weird behavior 2:

  • I scroll up to "Sign device into a specific network"
  • I enter "AndroidWifi" into the SSID input
  • I put "password" in the password input
  • I click "connect" and it says Network in range :)
  • I wait 10 seconds
  • I scroll down and click "Get connection status" and it says "You're not connected :(" ๐Ÿ‘Ž
  • I exit the app check the Android settings, and it says "No Network" ๐Ÿ‘Ž

2. However, running ExampleAPI25 app on on Android 7.1.1:

Expected behavior 1:

  • Ensure network is "Forgotten" from the Android Settings
  • I click "Get connection status" and it says "You're not connected :("
  • I click Current SSID and it says "unknown ssid" โœ…

Expected behavior 2:

  • I scroll up to "Sign device into a specific network"
  • I enter "AndroidWifi" into the SSID input
  • I put "password" in the password input
  • I click "connect" and it says Network in range :)
  • I wait 10 seconds
  • I scroll down and click "Get connection status" and it says "You're connected :)" โœ…
  • I exit the app check the Android settings, and yes, we are connected to "AndroidWifi"! โœ…

I hope this helps! Please let me know how I can help further debug.

Cannot use functions as a promise

I am using bluebirds 'promisifyAll' to make all the functions of this library return a promise. However, it always throws an error with the return value as the error message.

import reactNativeAndroidWifi from 'react-native-android-wifi'
import { Promise } from 'bluebird'
const androidWifi = Promise.promisifyAll(reactNativeAndroidWifi)

async function asyncCall() {
const result = await androidWifi.getIPAsync() // throws error at this point
}

asyncCall();

Connect to hidden WiFi networks

findAndConnect method can't connect to hidden WiFi networks.
Is it possible to add this feature or is there any other workarounds?

Cannot find symbol Build.VERSION_CODE.N

When compiling an application appears this error. It seems that NOUGAT version code is not defined in AndroidWifiModule.java:110. I've tried everything (the targetSdk is actually correct) but the only solution was to substitute that with the constant 24.

forceWifiUsage permissions bug

We are currently requesting an advanced permission ACTION_MANAGE_WRITE_SETTINGS when calling forceWifiUsage(true) on all Android SDK versions >= 23(M). However, this permission is only needed in SDK 23(specifically 6.0.0), as this was a bug and was fixed in all later versions including 6.0.1 and SDK 24+. We should not be prompting to extra permissions or checking canWrite permissions for SDK 24+ when calling forceWifiUsage.
More info:
https://stackoverflow.com/questions/32185628/connectivitymanager-requestnetwork-in-android-6-0#answer-33509180

It doesn't work with RN 0.43.0

Maybe you should update this library, because when i add with npm and using in app. It doesn't work with RN 0.43.0 and react: ^16.0.0-alpha.6

Cannot connect to WIFI if I first enter wrong password and after that try with correct one

I use next code to connect to WIFI

wifi.findAndConnect(ssid, password, (found) => {
  if (found) {
    console.log("wifi is in range");
  } else {
    console.log("wifi is not in range");
  }
});

First i tried with wrong password and I see message "wifi is in range"
But I never connected of course and this is expected result.
After that i tried to enter correct password and I see same message but i never connected to wifi which is unexpected result.
If I enter correct password in the very beginning when i open my app it works correctly.
Do you have any idea why I cannot connect to wifi after first try with wrong password and after that with correct one

Rescan Wifi List

I am trying to rescan wifi network list.

I did the following.

_onRefresh() {
     this.setState({refreshing: true});
     this.getWifiNetworks();
   }
getWifiNetworks() {
    wifi.loadWifiList((wifiStringList) => {
      var wifiArray = JSON.parse(wifiStringList);
      this.setState({
        wifiList: wifiArray,
      });
      let selectedSsidDefault = this.state.wifiList[this.state.selected1];
      this.setState({ ssid: selectedSsidDefault.SSID });
      this.setState({refreshing: false});

    },
      (error) => {
        console.log(error);
      }
    );
  }
refreshControl={
            <RefreshControl
              refreshing={this.state.refreshing}
              onRefresh={this._onRefresh.bind(this)}
            />
          }

but no luck.

how can i rescan available wifi list?

findAndConnect clones WiFi configuration on Android 6

If it is an already configured by user connection on Android 6 findAndConnect method clones WiFi configuration and connects to the cloned one.

According to Android 6.0 Changes

Your apps can now change the state of WifiConfiguration objects only if you created these objects. You are not permitted to modify or delete WifiConfiguration objects created by the user or by other apps.

iterator on a null object using findAndConnect

I used this module some time ago and it worked fine. Now i have this error:
photo5866438646868060782

this is my code (s,p,l are ssid,password and link to open)
`wifi.findAndConnect(s,p, (found) => {
if (found) {
console.log("wifi is in range");

if(!l.startsWith("http://"))
Linking.openURL("http://"+l).catch(err => console.error('An error occurred', err));

else
Linking.openURL(l).catch(err => console.error('An error occurred', err));

}else{
console.log("wifi is not in range");
}
});`

WIFI Signal Strength

Hi, How Can I get WIFI Signal Strength using this module? Any code sample would be appreciable.

need to able location in order to use wifi

I don't understand why I have to enable location manually or programatically in order to use the wifi functionality.

"react-native": "^0.59.0",
Gradlew 3
targetSdkVersion 27
compileSdkVersion 28

Suggest to add getServiceAddress() method

@ReactMethod
public void getServerAddress(final Callback callback) {
DhcpInfo dhcpinfo = wifi.getDhcpInfo();
String stringip=longToIP(dhcpinfo.serverAddress);
callback.invoke(stringip);
}

Wifi not connecting on Android Oreo API 26

Anyone having the same issue? It is working on Lollipop and Nougat. But on Oreo, it seems that I couldn't connect to any wifi. It seems like it tries to connect for a while and then disconnect and connect to another saved wifi. When I manually try to connect to the wifi from wifi settings page, it wouldn't connect (manually) unless I forget the network.

Feature request: Get wifi protocol / PHY standard

I would be nice for network diagnostics to get the wifi (IEEE 802.11) protocol / PHY standard that is currently used by a network connection.

E. g. if the network connection is using the a, b, g, n, ac or other protocol for communication.

I have tried to search this for Android, and it may seem like it is not possible to read the protocol directly, but that it could be inferred by reading the link speed. But I couldn't find other sources to confirm this.

findAndConnect

Hi ,
my phone version is android 8.1.0 ,when i try to call this function to switch to another wifi AP.
the callback function will retrun "console.log("wifi is not in range");" .
but i try the low verison ,it works fine.
can you fix for andoird 8.1.0?

loadWifiList when device screen off

Hi,

I would like to periodically invoke loadWifiList function in order to log nearby Wifi networks data.
In order to log this data even if the app is not in foreground I'm using an external library (react-native-background-timer). However, when device screen is switched off, the application keeps on logging periodically wifi data but it doesn't refresh them, that is it continues to log the data it retrieved the last time the screen was on.
When the screen is switched on again, the app logs new data correctly.

Is there a way to make the app refresh wifi data even if the screen is switched on?

I'm testing my app on an android device with 5.1 OS version

Works in debug, but not in release for android

I can connect to the wifi SSID when I am running in debug in react-native, but when I create an APK, the same phone does not ever notice when it is connected to the SSID. I see it connect, buy my code loops and checks the current wifi ssid to see if it is actually connected, and that code never is successful. Any Ideas?

react-native-android-wifi install and Link doesnt work

Hi there,

Followed the steps to install the library and tried linking both automatic and manually. When am trying to call the one of the method am getting an error "Undefined is not an object (evaluating "wifi.setEnabled"). Infact, same issue with other methods as well.

Please let me know if I missed any steps to use this library. Thank you.

Cheers,
Vinay.

findAndConnect not working properly on Android 8.0

Hello, i have tested on LG G6 on android 8.0, a Sony on android 8.0 and Asus zenpad on 7.0.

On the zenpad all working
On the LG and Sony, all working, but not the findAndConnect. The wifi network disconnect from the current network, and ( i have debug java ), the function connectTo return true, but the wifi dont connect to wanted network, and reconnect to previous network ...

I've test on an Open network, and a secure network, with and wihout internet on both

This seem arrive only on android 8.0, i can't find a fix ... An idea ?

Link manually not working

I try to use the library by link manually. But when I try to write import com.devstepbcn.wifi.AndroidWifiPackage; , error cannot resolve symbol devstepbcn. Also how to know which version it is?

react-native-android-wifi has a changelog

Hi @devstepbcn,

first of all, thanks for the module. I appreciate your work and effort. One question though, can you add a changelog or release tags or anything that can help to see the progress, breaking changes and other notes about new versions? That would be very helpful when one decides to upgrade your module or not.

Thank you.

Missing information about reScanAndLoadWifiList error callback on README.md

The method reScanAndLoadWifiList has an error callback that needs to be passed as a parameter to it, but it is missing on the instructions on README.md

wifi.reScanAndLoadWifiList((wifiStringList) => {
  var wifiArray = JSON.parse(wifiStringList);
  console.log('Detected wifi networks - ',wifiArray);
});

If you guys need, I could send a PR adding it to the docs.

Thanks again for the lib, it works really well!

Deprecated API

Note: /react-native-android-wifi/android/src/main/java/com/devstepbcn/wifi/AndroidWifiModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Not sure what it is

updateNetwork fails for Android 6.0+ whenever the network was created by something other than this module

Starting in Android 6.0 apps can now only change a network configuration if they created it in the first place. https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-network

Meaning that if the network was created by another app or the user themselves, findAndConnect will always return false.

The code in question is in connectTo specifically the loop compares current wifi configuration to the new configuration.

for(WifiConfiguration wifiConfig : mWifiConfigList){
	if(wifiConfig.SSID.equals(conf.SSID)){
		conf.networkId = wifiConfig.networkId;
		updateNetwork = wifi.updateNetwork(conf);
	}
}

wifi.updateNetwork(conf) will always return -1 in the case described above.

To fix it, one can replace updateNetwork = wifi.updateNetwork(conf); with updateNetwork = conf.networkId;.

I can create a pull request if you are interested in this fix. Is there a reason why wifi.updateNetwork is used?

findAndConnect should only return true upon connection success

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?

//found returns true if ssid is in the range
wifi.findAndConnect(ssid, password, (found) => {
  if (found) {
    console.log("wifi is in range");
  }else{
    console.log("wifi is not in range");
  }
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.