jacobrosenthal / react-native-ble

Central role BLE for react native noble api surface
MIT License
168 stars 45 forks source link

Not registering iBeacon advertisment #28

Open warrenronsiek opened 7 years ago

warrenronsiek commented 7 years ago

Hi, I'm trying to use react-native-ble on an Iphone to detect IBeacons. When I do this using plain noble on my computer I get advertisements that look like this:

{
  localName: undefined,
  txPowerLevel: undefined,
  manufacturerData: <Buffer 4c 00 02 15 4e dc e9 15 9f bb 61 8b 47 f6 f2 03 bb dd 08 9a 3e fc ce 24 b8>,
  serviceData: [],
  serviceUuids: []
}

This is what I would expect. The first hex in the buffer corresponds to Apple's company identifier, and I verified that the uuid embedded in the buffer is the same as the one I'm advertising via IBeacon.

However, when I do this in a react native app (i.e. scanning with react-native-ble) and simply logging the results, the advertisement key is empty. However, it seems to work for non-IBeacon advertisments. E.g.

{ serviceData: 
   [ { uuid: 'fe9a',
       data: 
        { '0': 0, '1': 59, '2': 161, '3': 252, '4': 29, '5': 204, '6': 106, '7': 38,
          '8': 158, '9': 101, '10': 77, '11': 211, '12': 255, '13': 23, '14': 229,
          '15': 134, '16': 11, '17': 145, '18': 68, '19': 64 } } ],
  serviceUuids: [ 'fe9a' ]
}

This is the advertisement for some other bluetooth thing in my house. (Not sure exactly what it is).

I have tried detecting the IBeacons both in my own app and in the 'advertisement-discovery' example app, and the same problem happens: react-native-ble discovers things, but IBeacons advertisements are missing. What is going wrong here? Why can't react-native-ble detect IBeacon advertisements?

rclai commented 7 years ago

Apple doesn't let you detect iBeacon advertisements using the CBCentralManager, you have to use a completely different API. There's a React Native library that wraps that API already here.

warrenronsiek commented 7 years ago

Wow. I'll have to send Apple a card thanking them for keeping things simple and being so flexible...

If it is possible to expand 'react-native-ble' to cover the other API, then you can consider this a feature request. Otherwise you can close this.

jacobrosenthal commented 7 years ago

The original goal behind this implementation was to track the noble api, what we need is a new (separate) bleno shim ;)