tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+
https://www.npmjs.com/package/cordova-plugin-wifiwizard2
Apache License 2.0
123 stars 146 forks source link

wifiWizard2.scan() returns error "Uncaught (in promise) SCAN_FAILED" #109

Closed ghost closed 4 years ago

ghost commented 4 years ago

<!--

Have you read the plugins' Code of Conduct? By creating an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/tripflex/wifiwizard2/blob/master/CODE_OF_CONDUCT.md

-->

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

Description

Made an Ionic-React Project and added Capacitor via CLI, installed the plugin following the docs instructions of the plugin (https://ionicframework.com/docs/native/wifi-wizard-2), imported WifiWizard into my TSX file, created a new const instance of WifiWizard2, used the function "let results = await wifiWizard2.scan();", added android to capacitor and tested it in Android Studio with an Emulator. The console showed up an error: "Uncaught (in promise) SCAN_FAILED"

Steps to Reproduce

  1. Install the Ionic CLI
  2. Create the Ionic project via CLI (ionic start myApp blank --type=react)
  3. Add Capacitor Support via CLI (ionic integrations enable capacitor)
  4. Installed the plugin via CLI (npm install cordova-plugin-wifiwizard2, npm install @ionic-native/wifi-wizard-2, ionic cap sync)
  5. Open the project and insert this code into a TSX file: "const wifiWizard2 = new WifiWizard2; let results = await wifiWizard2.scan();"
  6. CLI: ionic cap add android
  7. Open Java Project in Android Studio and test it with an Emulator, Logcat puts out the Error

Expected behavior: return the results of the WIFI scan

Actual behavior: returns an error "Uncaught (in promise) SCAN_FAILED"

Reproduces how often: everytime

Versions

Ionic CLI: 6.11.0, Capacitor CLI: 2.4.0, OS: Windows 10, Android Studio Emulator uses API 30

ghost commented 4 years ago

Problem solved: You have to enable GPS in your mobile settings and give permissions to your app (in the app settings). If this hasn't been handled before, wifiWizard.scan() will return the error, but otherwise it will work.

Gsiete commented 4 years ago

What? Why? Does the App require GPS to work? In all android versions?

ghost commented 4 years ago

What? Why? Does the App require GPS to work? In all android versions?

In basic Android development (done with Java), there are also methods to scan for access points and to use them, it's required by Android to enable your Location Services and permit your app to use them, as seen in this official article: https://developer.android.com/guide/topics/connectivity/wifi-scan