Вопрос

I am working with a bluetooth hardware device and I am trying to get it to interface with my Trigger.IO application. It seems as though it is not possible, even though technically it should. Here are my steps so far:

  • Used the Trigger.IO module functionality to create a module which was able to successfully send and receive messages between the Trigger.IO app and native Java code

  • Created a native Android application which successfully communicated with the bluetooth hardware device

  • Ported my native Android bluetooth code over into my Trigger.IO module

At this point the custom module is included in the Trigger app and seems to starting correctly, but when I make a call that should initiate the bluetooth device connection logic I am getting errors about bluetooth permissions. I ensured that my module has the necessary bluetooth permissions within its AndroidManifest.xml, but my fear is that the base Trigger app does not have the required permissions.

These are logs that output within the LogCat when the attempting to start the bluetooth connection:

D/Forge: Native call module.startDevicePolling with task.params: {}
D/BluetoothManagerService: Message: 20
D/BluetoothManagerService: Added callback: Android.bluetooth.IBluetoothManagerCallback$Stub$Proxy@41f84218:true
W/dalvikvm: threadid=25: thread exiting with uncaught exception (group=0x41612ba8)
I/Process: Sending signal. PID: 11967 SIG: 9
E/AndroidRuntime: FATAL EXCEPTION: Incoming Data Thread
E/AndroidRuntime: Process: io.trigger.forge42a1430afae511e2a0e61231392b77b0, PID: 11967
E/AndroidRuntime: java.lang.SecurityException: Need BLUETOOTH permission: Neither user 10230 nor current process has android.permission.BLUETOOTH.

Looking at the AndroidManfiest.xml at the root of the deployed .APK it looks as though Trigger only has permissions for INTERNET and ACCESS_NETWORK_STATE. Anyone else run into this? I think if I can get the BLUETOOTH permission into the root AndroidManifest.xml that things will work, but that file is encoded to not make that easy.

Это было полезно?

Решение

Trigger.io does support the ability for module's to add permissions - see Changing build configuration

In summary:

  1. Add a build steps file in android/build_steps.json
  2. For your scenario, update the build steps file with: [ { "do": { "android_add_permission": { "permission": "android.permission.BLUETOOTH" } } } ]
  3. After changing the build steps for either Android or iOS it is important to update the inspector project

Другие советы

I was able to solve my problem by changing the local trigger android template to give me the permission I needed. This is obviously not ideal. It would be ideal to have the Trigger logic look at the native modules, derive the required permissions, and update their master AndroidManifest.xml accordingly.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top