Description
I'm running into issues with my svelte-native application when I try to instantiate the Bluetooth from the plugin inside my Worker.
I've created a demo project so I could more easily reproduce the issue (https://github.com/AdrianoOP/bluetooth-worker-test). I can make it work perfectly in the main thread, but in the Worker I an error when trying to instantiate the Bluetooth class. Before trying to instantiate the class I'm making sure that permissions have been granted.
Situation happens both with my simulator (Android 13) and cellphone (Android 11)
const communicator = new Bluetooth(); // throws the error below
Error: Trying to link invalid 'this' to a Java object Error: Trying to link invalid 'this' to a Java object
at new ScanCallBackImpl (file: app/webpack:/bluetooth-worker-test/node_modules/@nativescript-community/ble/index.android.js:466:0)
at new Bluetooth (file: app/webpack:/bluetooth-worker-test/node_modules/@nativescript-community/ble/index.android.js:1004:0)
at handleScanMessage (file: app/webpack:/bluetooth-worker-test/app/bluetooth-worker.ts:25:23)
at globalThis.onmessage (file: app/webpack:/bluetooth-worker-test/app/bluetooth-worker.ts:10:18)
At the moment I suspect the issue is somewhere inside this function:
Line 539 in 4c4d55e
My package.json files:
package.json
package-lock.json