hoerresb / WifiWizard

A Cordova plugin for managing Wifi networks
Apache License 2.0
205 stars 178 forks source link

android-sdk 23 need permission ACCESS_COARSE_LOCATION #110

Open ytfhwfnh opened 7 years ago

ytfhwfnh commented 7 years ago

when you use getScanResults() method to get wifi list with android 6.0, you need permission ACCESS_COARSE_LOCATION.

ytfhwfnh commented 7 years ago

In my ionic2 project:

AndroidManifest.xml I used: <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

project.properties I used: target=android-23

I can permit ACCESS_COARSE_LOCATION.

No authorization dialog box is displayed in other cases.

chr4ss1 commented 7 years ago

For Android6.0(SDK >= 23), they have changed the permissions model, now you have to ask permissions manually inside the app as far I know - uses-permission doesn't do anything.

As far I understand, the reason why it works is that you're compiling against targetSdkVersion="22" (Android <= 5.1) which has backwards compability with newer androids as well. If you use that SDK version, your app will have those permissions by default.

You can get the same effect if you add this line to config.xml:

<preference name="android-targetSdkVersion" value="22"/>

adhambadr commented 7 years ago

for newer versions of Android just use this plugin https://github.com/NeoLSN/cordova-plugin-android-permissions , request / check for the ACCESS_COARSE / FINE permission & in the success callback start the scan. It worked for me @ SDK 25