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

Version 3.3.0 for Android 10+ #127

Open
matscav opened this issue Jul 5, 2021 · 13 comments
Open

Version 3.3.0 for Android 10+ #127

matscav opened this issue Jul 5, 2021 · 13 comments

Comments

@matscav
Copy link

matscav commented Jul 5, 2021

Hi all,

I just forked this pull request from @klich3: Pull Request

I made some fixes and I did create another function (suggestConnection) for the new API. You can read more here

If you want to test my code or you need to have this working, here is my repo: 3.3.0
Run cordova plugin add https://github.com/matscav/WifiWizard2#dev

In Android 10+ all you have to do is call WifiWizard2.suggestConnection(SSID, password, algorithm, isHiddenSSID) instead of WifiWizard2.connect(SSID, bindAll, password, algorithm, isHiddenSSID)

Hope this can help anyone!

@RolfDohrmann
Copy link

RolfDohrmann commented Dec 7, 2021

I made some fixes and I did create another function (suggestConnection) for the new API. You can read more here

If you want to test my code or you need to have this working, here is my repo: 3.3.0 Run cordova plugin add https://github.com/matscav/WifiWizard2#dev

In Android 10+ all you have to do is call WifiWizard2.suggestConnection(SSID, password, algorithm, isHiddenSSID) instead of WifiWizard2.connect(SSID, bindAll, password, algorithm, isHiddenSSID)

Hope this can help anyone!

Hello @matscav,

I have an Ionic project. It works with capacitor. I was able to install your plugin and to call the suggestConnection() method. My hope was that it would connect my test device (Samsung A50, Android 11) to the chosen SSID. This is the code:

WifiWizard2.suggestConnection(SSID, pw, algorithm, isHidden).then( res => { console.log(res); }, err => { console.log(err); } );

I get back as res in the console:

STATUS_NETWORK_SUGGESTIONS_ADDED

This is no error, which is great! However, the test device did not connect to the SSID. Is this the expected behaviour? What would I need to do to connect to the SSID?

Btw, are you still a freelancer? The company in which I work is looking for a plugin developer. Drop me a note if you are interested.

Regards, Rolf

@RolfDohrmann
Copy link

This is no error, which is great! However, the test device did not connect to the SSID. Is this the expected behaviour? What would I need to do to connect to the SSID?

Ok, I assumed that suggestConnection() is a replacement for connect() which has to be used if Android >= 10. That was wrong. The connection works using a Samsung A50 / Android 11 when using the method specifierConnection().

@RolfDohrmann
Copy link

Now I want to restore the original connection. My idea is that I use disconnect(). And then the Smartphone maybe reconnects to the original network. Using disconnect():

If I use no SSID then I get this answer: ERROR_DISCONNECT.
If I use the SSID of the currently connected network then I get this answer: DISCONNECT_NET_ID_NOT_FOUND

So I guess this DISCONNECT_NET_ID_NOT_FOUND is the problem.

The documentation explains:
"Unable to determine network ID to disconnect/remove (from passed SSID)"

So I tried getConnectedNetworkId(), which however gives me a result (e.g. 4)

I tried the disable(). I first got the networkId by using getConnectedNetworkId(), then I call disable() using this networkId. The result is:

UNABLE_TO_DISABLE

Documentation: "Android returned failure in disabling network". And I read: "Please note that most newer versions of Android will only allow you to disable networks created by your application"

So what does it mean: "networks created by your application"?

Does this mean that the app is able to connect to a network, but is not able to disconnect?

@f18nfz
Copy link

f18nfz commented Oct 29, 2022

Hi all,

I just forked this pull request from @klich3: Pull Request

I made some fixes and I did create another function (suggestConnection) for the new API. You can read more here

If you want to test my code or you need to have this working, here is my repo: 3.3.0 Run cordova plugin add https://github.com/matscav/WifiWizard2#dev

In Android 10+ all you have to do is call WifiWizard2.suggestConnection(SSID, password, algorithm, isHiddenSSID) instead of WifiWizard2.connect(SSID, bindAll, password, algorithm, isHiddenSSID)

Hope this can help anyone!

Thanks, but I can't seem to enable WiFi (turn WiFi on) if it's off on Android 10 devices (or where I target SDK>=30 (I've tried your fork too).
(I get the message: Uncaught ReferenceError: enabled is not defined) or VERIFY_ERROR_ENABLE_WIFI
Does the function WifiWizard2.setWifiEnabled(enabled); work with devices running Android 10? Or is this currently impossible as per: https://issuetracker.google.com/issues/128554616?pli=1

Thanks!

@matscav
Copy link
Author

matscav commented Nov 2, 2022

Hello,

I only added this function "suggestConnection". Maybe you can put some work on those functions that are not working and give it back to community.

Regards!

@klich3
Copy link

klich3 commented Nov 2, 2022

Hi "matscav" and "f18nfz", in my branch you have both connections one for oldes versions connect directly, and new one with suggest. The Suggest is for new gen Androids oldest one its not working properly because you need authorizations of user.

I thing this project is died and not supported by creator....

@bartek-ddh
Copy link

Now I want to restore the original connection. My idea is that I use disconnect(). And then the Smartphone maybe reconnects to the original network. Using disconnect():

If I use no SSID then I get this answer: ERROR_DISCONNECT. If I use the SSID of the currently connected network then I get this answer: DISCONNECT_NET_ID_NOT_FOUND

So I guess this DISCONNECT_NET_ID_NOT_FOUND is the problem.

The documentation explains: "Unable to determine network ID to disconnect/remove (from passed SSID)"

So I tried getConnectedNetworkId(), which however gives me a result (e.g. 4)

I tried the disable(). I first got the networkId by using getConnectedNetworkId(), then I call disable() using this networkId. The result is:

UNABLE_TO_DISABLE

Documentation: "Android returned failure in disabling network". And I read: "Please note that most newer versions of Android will only allow you to disable networks created by your application"

So what does it mean: "networks created by your application"?

Does this mean that the app is able to connect to a network, but is not able to disconnect?

still a problem in 2023

@EYALIN
Copy link

EYALIN commented Apr 12, 2023

@klich3 @f18nfz @matscav @RolfDohrmann
some of the issues have been fixed in my forked repo:
https://github.com/EYALIN/community-cordova-plugin-wifi-wizard

you can install it as an npm package:
cordova plugin add community-cordova-plugin-wifi-wizard --save

@EduardSat
Copy link

EduardSat commented Jul 3, 2023

@EYALIN
Hello! I'm trying to use your implementation with capacitor and ionic/react. Can yo uhelp with installing your library?
Trying to import your library to use functions from it: import { WifiWizard2 } from 'community-cordova-plugin-wifi-wizard'. Hovewer, i'm getting error: Cannot find module 'community-cordova-plugin-wifi-wizard' or its corresponding type declarations.

@EYALIN
Copy link

EYALIN commented Jul 3, 2023

@EduardSat you cannot import it directly.
or you can use the ionic wrapper, or you can use windows.wifiwizard2 (not sure if it's there or inside window.plugins)

hope that in the future I will be able to make it strongly typed.

@EduardSat
Copy link

@EduardSat you cannot import it directly. or you can use the ionic wrapper, or you can use windows.wifiwizard2 (not sure if it's there or inside window.plugins)

hope that in the future I will be able to make it strongly typed.

@EYALIN . i found the way to use your edited version. However, when i'm trying to connect to wifi using WifiWizard2.suggestConnection(), i'm always getting STATUS_NETWORK_SUGGESTIONS_ERROR. Can you suggest the way to solve that problem? And also i'm getting the error: DISABLE_NETWORK_NOT_FOUND, when i'm calling WifiWizard2.disable('ssid')

@EYALIN
Copy link

EYALIN commented Jul 3, 2023

@EduardSat i'm using it like this:

  if (+this.device.version > 10) {
                result = await (window as any).WifiWizard2.specifierConnection(wifiNetwork,wifiPassword, networkType, false);
            } else {
                result = await (window as any).WifiWizard2.connect(wifiNetwork, true,wifiPassword, networkType);
            }

regarding the disable, i think it's deprecated from Android 12.

@j-bill
Copy link

j-bill commented Jul 16, 2024

@EduardSat

while this might be somewhat late for you it might help others that stumble across this issue like I have. All the disconnect, delete and remove functions didn't work on API level 34, so I've taken EYALINs version and made two changes.

  1. SpecifierConnection now saves the network callback as a global variable.
  2. The new releaseNetwork function then uses that network callback for unregisterNetworkCallback.

WifiWizard2.releaseNetwork();
Removes connections created through specifierConnection

The plugin can be added like so:
"cordova-plugin-wifiwizard2": "git+https://github.com/j-bill/community-cordova-plugin-wifi-wizard.git#3.4.0",

When I have the time I'll take a look at the suggest function to see if releaseNetwork will work there too.

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

No branches or pull requests

8 participants