e-mission / e-mission-data-collection

Repository for our own data collection
BSD 3-Clause "New" or "Revised" License
4 stars 19 forks source link

Bluetooth permissions functionality #218

Closed louisg1337 closed 7 months ago

louisg1337 commented 8 months ago

Incorporated new functionality to request bluetooth permissions on Android.

shankari commented 7 months ago

@louisg1337 can you please:

the-bay-kay commented 7 months ago

... Also, where are the iOS changes?

This is a question I can answer! From what I understand, the changes were in plugin.xml, line 216:

    <config-file target="*-Info.plist" parent="NSBluetoothAlwaysUsageDescription">
      <string>We need Bluetooth access to interact with BLE beacons for the fleet version of the app.</string>
    </config-file>

This permission was then checked on the UI side, in this component. As we we understood it, the Classic plugin on iOS only worked with a preset list of peripherals (see screenshot below), and effectively did not scan. Because this wasn't functional, we opted to leave a "Classic Not Available" error message here! I can run another test on this branch if need be: the old code for iOS can be found here.

ios_bluetooth

louisg1337 commented 7 months ago

indicate testing done (showing the new permissions)

To answer your question about why we wrote our own permissions, the plugin did have a way to request permissions but it was too all over the place. It involved a lot more hassle as the permissions for the plugin requests multiple permissions that we don't need (locations + bluetooth connecting). We also will eventually need to incorporate the permissions for bluetooth so we figured why not just do it now. For testing done, I tested 3 cases on Android only.

I tested what happens when a user, from a fresh install, tries to use the bluetooth scanner. The result is as follows. Clicking allow then takes you to the scanner page.

Screenshot_1710354268

After that, from a fresh install, I tried to deny the permissions. This is the result. Clicking the scanner again will pop up the previous permissions request.

Screenshot_1710354281

Then finally, I tried revoking the permissions to see if it would let you use the scanner, and it still pops up the same permission request as the first picture.

remove the whitespace

Just pushed a new commit with the whitespace removed, sorry about that!

answer the question about iOS

Katie hit the nail on the head! Because the classic didn't work the way we wanted on iOS, we chose to forego it. We did need that line in the plugin.xml to allow us to build or else it causes an error. Along with that, to our knowledge, there is no way to directly ask the user for bluetooth permissions. The way it happens, is iOS requests permissions whenever the CBCentralManager is initialized (see this github post). This change had to occur in the bluetooth classic plugin itself, so we made the changes here in this forked version of the plugin. However, since we aren't using the bluetooth classic for iOS we just forewent it and popped up the error like Katie said.