innoveit / react-native-ble-manager

React Native BLE communication module
http://innoveit.github.io/react-native-ble-manager/
Apache License 2.0
2.11k stars 761 forks source link

Cant find any device with iOS #424

Closed tal987 closed 5 years ago

tal987 commented 5 years ago

Hey guys I have been trying to discover device and connect but non of that work. I wouldn't be able to find any device and I know there are a few devices that are advertising.

my code is:

   componentDidMount() {
      BleManager.start({showAlert: true}).then(() => {
     // Success code
      console.log('Module initialized');
      });
         }

   startScan() {
     BleManager.scan([], 5, true).then((results) => {
      console.log('Scanning...',results
        );
        });

       BleManager.connect('B8211E4A-0989-6282-9970-5A1B2764A921')
      .then(() => {
      // Success code
       console.log('Connected');
             })
           .catch((error) => {
           console.log('NOTConnected');

           // Failure code
        console.log(error);
            });

        BleManager.getConnectedPeripherals([]).then((results) => {
            if (results.length == 0) {
            console.log('No connected peripherals')
                 }
              console.log(results);
                 });

                      }

nothing comes up... what am I doing wrong here?

Thanks

marcosinigaglia commented 5 years ago

Hi @tal987 ,are you handle the BleManagerDiscoverPeripheral event?

tal987 commented 5 years ago

@marcosinigaglia what do you mean by handle? The code I added in my post is all I do except to the render. But I can’t even connect or discover any device. Im trying that with physical device that the develop app version installed on the device

srikanthkyatham commented 5 years ago

@tal987 could you answer the following

  1. which platform are you using iOS or Android.
  2. You using it in foreground I assume Yes?
  3. are you trying to connect to ibeacon or anything else ?
tal987 commented 5 years ago

@srikanthkyatham 1. IOS

  1. Yes
  2. First im trying only to scan and find something... I check with my iPhone for any bluetooth connection around me and there's a few: my Mac, my AirPods and more but can't find anything...
Ilario17 commented 5 years ago

@tal987 have you found a solution?

srikanthkyatham commented 5 years ago

For me I was not able to scan on the background, apple insists on having the service uuids in the scan. Otherwise in the foreground you should be able to find all the beacons. I did not have any issue using the module.

Assuming You have followed setup instructions in setting up the permissions.