Rexios80 / polar

‎‎‎‎‎This is a Dart plugin wrapper for the Polar SDK on Android and iOS
https://pub.dev/packages/polar
BSD 3-Clause "New" or "Revised" License
17 stars 14 forks source link

Return whether requested permissions have been granted #18

Closed LorenzSchueler closed 1 year ago

LorenzSchueler commented 1 year ago
Rexios80 commented 1 year ago

Why do you want to do nothing in connectToDevice if the permissions request fails? The caller wouldn't know anything went wrong. The native call at least throws an exception which is what the dart code should also be doing if we aren't making the native call, but then we might as well just call the native method anyways.

LorenzSchueler commented 1 year ago

You are right about that. I was honestly more interested in getting to know whether permissions have been granted. I also thought about returning the permission status from requestPermissions directly, but because the are multiple permissions requested I'm not sure on how to combine the status from those requests. Therefor I just went with the bool. Should I revert the changes to connectToDevice and are you fine with those to requestPermissions?

LorenzSchueler commented 1 year ago

Furthermore is there any advantage in requesting bluetoothConnect if bluetoothScan is not granted? If we can't discover devices we can't connect to them anyway. One option would be to check if bluetoothScan is granted. If so, request bluetoothConnect and return its PermissionStatus. If not return the PermissionStatus from bluetoothScan. The only question is what to return if we are not an Android >23? Do we simply return null (requires return type to be Future<PermissionStatus?>)?

Rexios80 commented 1 year ago

You can connect to devices without scanning