react-native-ble-advertiser
react-native-ble-advertiser copied to clipboard
Cannot read property 'secCompanyId' of null
I'm getting this error just doing this
import BleAdvertise from 'react-native-ble-advertise'
BleAdvertise.setCompanyId(0x00e0)

Should it not be import BLEAdvertiser from 'react-native-ble-advertiser'
?
If this doesn't work I'll have a more in-depth look after your response :)
import BLEAdvertiser from "react-native-ble-advertiser"; const APPLE_ID = 0x4c; const MANUF_DATA = [1, 0]; // No scanner filters (finds all devices inc iPhone). Use UUID suffix to filter scans if using. const SCAN_MANUF_DATA = Platform.OS === "android" ? null : MANUF_DATA;
BLEAdvertiser.setCompanyId(APPLE_ID);
@fhllnd its not work for me xcode keep throw error TypeError: Cannot read property 'setCompanyId' of null, js engine: hermes', reason: 'Unhandled JS Exception: TypeError: Cannot read property 'setCompanyId' of null, js engine: hermes
Try to do
cd ios/
bundle exec pod install
and then killing Metro and running your app again.
hmm i did that and it seems like in podfile.lock there is no react-native-ble-advertiser that is the only different between my project and example project
it seems like only my project unable to detect this lib to import it into podfile.lock other project work fine and i have no idea why
Yes, there is something going on in your config. Maybe some interference between native modules?
I just created a new project, installed this lib, run pod install, and added those lines and it seems to work just fine. I am not sure how to replicate the issue.
@Zero6d it seems to be working for me in my own project fine, just upgraded to 0.0.17 on ios and android with npm i @latest.
There apparently has been an issue that's appeared since 2022/11/4 which has caused run-android to fail, so I've created a PR to update the example to rn 0.70.5 mentioned here this should allow you to set up the example and debug between the working example and your own project.
You could try using the .tgz produced with npm pack
in the root of the example project and see if that works. install it using npm i file:./react-native-ble-advertiser-0.0.17.tgz
with relative path from package.json.
i have to manually add pod 'react-native-ble-advertiser', :path => '../node_modules/react-native-ble-advertiser/ios' to podfile to fix cannot read property error but i get new error when try to build apk on android and i already made new issue can you check this out ? @fhllnd https://github.com/vitorpamplona/react-native-ble-advertiser/issues/43
same here after update to RN 0.69.7
Adding
pod 'react-native-ble-advertiser', :path => '../node_modules/react-native-ble-advertiser/ios'
inside ios/PodFile under
target 'APPNAME' do
use_expo_modules!
config = use_native_modules!
...
pod 'react-native-ble-advertiser', :path => '../node_modules/react-native-ble-advertiser/ios'
Resolved the null error for me.