Search code examples
androidiosflutterbluetoothcross-platform

Perform a specific action on Bluetooth remote button click


I am currently working on a Flutter app which is meant to be cross-platform, for Android and iOS.

One of the functionality this app has to offer, is to perform a specific action when the button of a Bluetooth remote is pressed. Currently, we are using this kind of remote which does job. The way it works is by simulating the press of the "Volume up" physical key of the telephone. Therefore, all I need to do in my Flutter app, is to listen for the key press and perform the action.

The issue is that, per the 2.5.9 Guideline of the AppStore, it is forbidden to "alter or modify the function of standard switches, such as the Volume Up/Down and [...]".

I've spent a great amount of time looking for an alternative, but have failed to find one. I'm fairly certain there should be one, but my knowledge in Bluetooth communication are still not the best. I guess my questions are :

  1. Do Bluetooth remotes that send a simple "signal", rather than simulating physical device keys exist ?
  2. From my Flutter app, would I then be able to listen and "wait" for the signal, to then perform the action ?

I have found that there exists some customizable development kit that could fulfill this purpose. However, it seems quite cumbersome to do, and I have limited time.

Thanks in advance for any help !


Solution

  • The Bluetooth remote you are using might be using the HID (Human Interface Device) protocol over GATT (Generic Attribute Profile). This standardized protocol is already recognized and interpreted by the Android/iOS system, meaning your app is not bridging the remote and the mobile device. Your app listens for the volume key press and invokes your action, this is not a good solution.

    You should avoid using a remote / ble device that uses a standard protocol like the HID (Human Interface Device) protocol over GATT (eg, ble mouse, joystick, keyboard) and choose a device that uses a custom protocol, hence the system cannot directly communicate with the ble device. FeasyBeacon would be such a ble device.

    Now here the communication will be like ble device -> App -> Mobile device. Listen for an event in the app (ble characteristic to which you need to listen will be in the docs provided with device), execute the action on event.