How to use the react-native-ble-manager.start function in react-native-ble-manager

To help you get started, we’ve selected a few react-native-ble-manager examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zhanguangao / react-native-ble-manager-demo / src / BleModule.js View on Github external
start(){
        BleManager.start({showAlert: false})
            .then( ()=>{
                this.checkState();
                console.log('Init the module success.');                
            }).catch(error=>{
                console.log('Init the module fail.');
            });
    }
github innoveit / react-native-ble-manager / example / App.js View on Github external
componentDidMount() {
    AppState.addEventListener('change', this.handleAppStateChange);

    BleManager.start({showAlert: false});

    this.handlerDiscover = bleManagerEmitter.addListener('BleManagerDiscoverPeripheral', this.handleDiscoverPeripheral );
    this.handlerStop = bleManagerEmitter.addListener('BleManagerStopScan', this.handleStopScan );
    this.handlerDisconnect = bleManagerEmitter.addListener('BleManagerDisconnectPeripheral', this.handleDisconnectedPeripheral );
    this.handlerUpdate = bleManagerEmitter.addListener('BleManagerDidUpdateValueForCharacteristic', this.handleUpdateValueForCharacteristic );



    if (Platform.OS === 'android' && Platform.Version >= 23) {
        PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
            if (result) {
              console.log("Permission is OK");
            } else {
              PermissionsAndroid.requestPermission(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
                if (result) {
                  console.log("User accept");
github anchetaWern / RNFaceAttendance / App.js View on Github external
constructor(props) {
    super(props);

    this.peripherals = [];

    BleManager.enableBluetooth()
      .then(() => {
        console.log('Bluetooth is already enabled');
      })
      .catch((error) => {
        Alert.alert('Enable bluetooth', 'You need to enable bluetooth to use this app.');
      });

    BleManager.start({showAlert: false})
      .then(() => {
        console.log('Module initialized');
      });

    if (Platform.OS === 'android' && Platform.Version >= 23) {
      PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
        if(!result){
          PermissionsAndroid.requestPermission(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
            if(!result){
              Alert.alert('You need to give access to coarse location to use this app.');
            }
          });
        }
      });
    }
  }
github adafruit / glider / App.js View on Github external
useEffect(() => {
        if (currentAppState === 'active') {
          console.log('App has come to the foreground!', bleState);
          BleManager.start({showAlert: true});
          BleManager.checkState();
        } else {
            if (peripheral) {
              changeCode({"type": "disconnect", "peripheral_id": peripheral.id});
              BleManager.disconnect(peripheral.id);
            }

            setBleState("disconnected");
        }
    }, [currentAppState]);
github zhanguangao / react-native-ble-manager-demo / demo for v3.2.1 deprecated / app / BleManager.js View on Github external
start(){
        BleManager.start({showAlert: false})
            .then( ()=>{
                console.log('Init the module');
            });
    }
github CalPlug / Espressif_ESP32-Scale / React Native / BLE Demo / src / ble_manager / BLE.js View on Github external
componentDidMount() {
    AppState.addEventListener('change', this.handleAppStateChange);

    BleManager.start({showAlert: false});

    this.handlerDiscover = bleManagerEmitter.addListener('BleManagerDiscoverPeripheral', this.handleDiscoverPeripheral );
    this.handlerStop = bleManagerEmitter.addListener('BleManagerStopScan', this.handleStopScan );
  
    if (Platform.OS === 'android' && Platform.Version >= 23) {
        PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
            if (result) {
              console.log("Permission is OK");
            } else {
              PermissionsAndroid.requestPermission(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
                if (result) {
                  console.log("User accept");
                } else {
                  console.log("User refuse");
                }
              });
github bailabs / tailpos / src / stories / components / PrinterSettingsComponent.js View on Github external
onCreate() {
    this.props.availableDevicesChangeValue(true);
    BleManager.start().then(() => {
      BleManager.scan([], 10, false).then(() => {
        NativeAppEventEmitter.addListener(
          "BleManagerDiscoverPeripheral",
          data => {
            if (data.name === null) {
              for (let i = 0; i < this.props.addedDevice.length; i += 1) {
                if (data.id === this.props.addedDevice[i].macAddress) {
                  dup += 1;
                }
              }
              for (let i = 0; i < devices.length; i += 1) {
                if (data.id === devices[i].macAddress) {
                  dup1 += 1;
                }
              }
              if (dup === 0) {