alexkendall / react-native-bluetooth-cross-platform

Cross-Platform Bluetooth & WiFi React Native Module. Powered by underdark http://underdark.io/.
179 stars 35 forks source link

undefined is not a constructor #24

Closed earlvanze closed 6 years ago

earlvanze commented 6 years ago

new _reactNative.NativeModules.NetworkManager() is not a constructor, and NativeModules.NetworkManager is not an object. Am I missing something? I am able to import your plugin/module properly and initialize the NetworkManager class, then call the BluetoothCP.advertise("WIFI") function which calls NativeManager.advertise(kind) but NativeManager.advertise is undefined, because NativeModules.NetworkManager is undefined.

Any ideas?

By the way, I am using React Native with Expo. I imported and called the module from App.js and/or one of my screens. Calling the functions/methods you implemented is not a problem.

import BluetoothCP from 'react-native-bluetooth-cross-platform'; ... render() { BluetoothCP.advertise("WIFI"); ... }

earlvanze commented 6 years ago

I figured it out, it's because of Expo. I need to detach from Expo and build the project into native Android/iOS before installing this native module.

https://docs.expo.io/versions/latest/guides/detach.html