tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+

Home Page:https://www.npmjs.com/package/cordova-plugin-wifiwizard2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WifiWizard2.getCurrentSSID returns unknown on Android 8.1

gregoiregentil opened this issue · comments

So first, thank you for extending the work of WifiWizard. It was a major pain that the development of that plugin was stopped.

Android 8.1 seems to have changed things for Wi-Fi and getCurrentSSID returns unknown. I was seeing this problem with WifiWizard. I googled, found and upgraded to WifiWizard2. But I still see the same issue.

Note that it's working on Android 8.0.1.

The bug seems very similar to this problem:
http://piunikaweb.com/2017/12/21/google-fixes-android-8-1-wifivpn-issue/
though it has nothing to do with VPN in my case.

Do you have a device running Android 8.1 somewhere?

Thanks for reporting this, which branch of this project are you using? There was a known issue that was just fixed where the documentation stated the function to use was getConnectedSSID but the actual function was getCurrentSSID ... this has been fixed and changed to getConnectedSSID ... can you please try it now and see if it works for you?

This may also have been related to the way that current SSID was obtained in the 2.x branch, which was modified in the 3.x branch.

I tested this using the 3.0.0 branch, and the WifiWizard2 demo project on Android 8.1 and didn't have any issues returning current SSID, but yes after reading that post and your specific issue ... it may be specifically related to this problem and using VPN

From my testing Android Oreo+ has created all kinds of issues with WiFi, so thank you for reporting this and please let me know if you find anything else

I have a lot of trouble and I really need to fix this problem as my app is in the hands of a lot of users. First, I have tried to put in config.xml:

and in package.json:

"wifiwizard2": "git+https://github.com/tripflex/WifiWizard2.git#a74b772ed081337666941e612515688194b3e598",

I have:
ionic --version
3.19.0
cordova --version
8.0.0

ionic tells me "Failed to restore plugin "wifiwizard2" from config.xml. Error: Failed to fetch plugin git+https://github.com/tripflex/WifiWizard2.git#a74b772ed081337666941e612515688194b3e598".

Then, I tried the same syntax with #3.0.0 instead, still no luck. I'm confused.

There are multiple problems, not necessarily all your fault :-)

First, ionic cordova plugin add is failing with github. I don't know why. But cordova plugin add alone works and I can add any version I want.

Secondly, with master as of February 24, the function is now indeed getConnectedSSID. But why did you change that? You are breaking compatibility with old code.

Thirdly, with master as of February 24, the function getConnectedSSID still reports unknown SSID on Android 8.1 while it's working on previous version of Android.

Fourthly, with version 3.0.0, the function getConnectedSSID is not called at all. I guess that the API and logic has changed too much with version 3.0.0. I'm a little bit confused by this last point.

I found the original problem. The application needs to be granted location permission by the user since Android 8.1.

In the end, I hacked the Android version of my ionic application with:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
	if (checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
		requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 0);
	}

Once again, the app needs the location permission to list Wi-Fi SSID - because with Wi-Fi information, you can determine the location of the device.

I think that the plugin should handle this situation.

I think that I missed this API: WifiWizard2.requestPermission()...

I think that I missed this API: WifiWizard2.requestPermission()...

Hi, have you solved problem adding WifiWizard2.requestPermission() for me it does'nt works the same with Andorid 8.1 :(

Not really. Sorry. I gave up on Ionic and developed a native app for Android. The only advice I can give you is to read all the elements of my thread. If I close the issue, it means that I managed to make it work.

This is related to the 2.x.x branch, which has been deprecated and the 3.x.x version of the plugin should be used. There is an open issue regarding this for 3.x.x #63

Old post, but this same problem still remains after all these years!
I could reproduce this issue on my Samsung Galaxy, Android 13, API 33.
To solve the problem I had to do two things:

  1. get Android permissions ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION at runtime using requestPermission()
  2. I had to turn on GPS on my mobile phone! Without this, getConnectedSSID() returns <unknown SSID> and getConnectedNetworkID() throws NO_CURRENT_NETWORK_FOUND.
    NOTE: In later versions of Android, you may also have to turn on 'Precise Location'.
    I got the hint from
    https://github.com/tripflex/WifiWizard2/issues/63