-
Notifications
You must be signed in to change notification settings - Fork 354
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
Scan in Android 6.0 #204
Comments
After doing some research, scanning for Bluetooth device's on Android 6.0 seems to require the Coarse Location permission. I modified the code to request for permission, but it's a little 'scary' looking to the average user since it asks "Allow {{appName}} to access this device's location?" If the user clicks deny, the error callback will return with an error named 'permissions'. You can use this to explain to the user why you're requesting permissions. I have a feeling this prompt will increase the number of support tickets I receive and decrease my ratings. :( By the way, if the user has paired the device and you use retrieveConnected, the coarse location permissions aren't needed. I also checked out the BluetoothLeScanner class introduced in API 21, but it requires coarse location permissions as well. Since API 21 and 22 don't request permissions at runtime, I'd need to add the Coarse Location permission to plugin.xml. I'll probably hold off on implementing this until I better understand the permissions impact. |
I've tried adding the permissions (BT, BTAdmin, Coarse) to both Manifest and plugin.xml, but it doesn't have any effect. |
Yah, even if you specify the permissions you still need to request to actually use them. Give me a few minutes and I'll have a dev branch with the changes. |
@agoransson You'll need to update to the latest Android Cordova version 5.0.0. I'm seeing if I can enforce that via the plugin.xml |
I found some more information now.
Still not firing the onLeScan callback. |
It shouldn't be an issue. I believe it just means no service UUIDs are used for filtering. Are you getting a permissions prompt at all? Since it doesn't seem to be calling the onLeScan callback, it must be getting stopped at a lower level somewhere. What's your javascript code look like? |
No permission prompt at all. I'm using https://github.com/randdusing/ng-cordova-bluetoothle - the only modification is multiple controller and template files. |
Are you sure you're using recently published code? |
Yep, installed with |
Ahh, can you check the app settings? Maybe the location permission is already set to yes. But that leads us back to the original problem. |
Hmm. Found it. Had to enable "Location" in the device settings - see this thread on stackoverflow http://stackoverflow.com/questions/33043582/bluetooth-low-energy-startscan-on-android-6-0-does-not-find-devices Getting all sorts of of scan results now. |
Interesting that it never prompted you for the permission, that's what it should have done... Glad it's working either way though! |
My 2 cents: many apps use BTLE to actually acquire coarse location by relying on known bluetooth Beacons... so in a way, this makes sense from a user information standpoint. Not very fair to apps that use BTLE for more worthy usage... |
Yep, at first I was annoyed, but I understand the permission requirement. |
There are some permission changes with Android 6.0 that seem to be causing scans to not work. I'm working on an update that should hopefully fix the issue.
The text was updated successfully, but these errors were encountered: