WifiWizard: getScanResults not working on Nexus 5 with Android 6.0.1

Hi, The plugin works wonderfully (setWifiEnabled, addNetwork, connectNetwork, disconnectNetwork, etc.)

startScan calls the success callback, but getScanResults always calls the success callback with an empty array.

we have used an androidManifest with the following pemissions:

 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Any ideas?

About this issue

Most upvoted comments

OK, I turned my GPS on and it didn’t work. But when I went into Settings -> App -> My App -> Permissions and allowed location it worked. Very odd one.

Confirmed that I needed to enable Location permissions in Android 6.0.1 to get getScanResults to work. I now request these permissions programatically with cordova-plugin-android-permissions

You have to ask for permissions at runtime. I used the plugin https://github.com/dpa99c/cordova-diagnostic-plugin to achieve this. Before calling getScanResults, I call window.cordova.plugins.diagnostic.requestLocationAuthorization(successCallback, errorCallback);

Please note that successCallback does not mean the user granted you permissions, it might also mean the user denied your permission. Read more at: https://github.com/dpa99c/cordova-diagnostic-plugin#requestlocationauthorization

AFTER enable GPS .it is ok. Its a bug in Andorid 6+

Even with GPS enabled it is not working… getScanResults still calls the success callback with an empty array. Any advice?