react-native-ble-advertiser icon indicating copy to clipboard operation
react-native-ble-advertiser copied to clipboard

Cannot read property 'secCompanyId' of null

Open carlosriveroib opened this issue 2 years ago • 10 comments

I'm getting this error just doing this

import BleAdvertise from 'react-native-ble-advertise'

BleAdvertise.setCompanyId(0x00e0)
Captura de Pantalla 2022-10-16 a las 21 15 49

carlosriveroib avatar Oct 16 '22 19:10 carlosriveroib

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 :)

finnholland avatar Nov 02 '22 05:11 finnholland

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

Screen Shot 2022-11-02 at 10 16 28

Zero6d avatar Nov 02 '22 06:11 Zero6d

Try to do

cd ios/
bundle exec pod install 

and then killing Metro and running your app again.

vitorpamplona avatar Nov 02 '22 18:11 vitorpamplona

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

Zero6d avatar Nov 03 '22 02:11 Zero6d

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

Zero6d avatar Nov 03 '22 03:11 Zero6d

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.

vitorpamplona avatar Nov 03 '22 13:11 vitorpamplona

@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.

finnholland avatar Nov 16 '22 01:11 finnholland

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

Zero6d avatar Nov 16 '22 03:11 Zero6d

same here after update to RN 0.69.7

AstanyTR avatar Dec 22 '22 18:12 AstanyTR

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.

Vercjames avatar Dec 28 '22 09:12 Vercjames