-1

I'm trying to look for other iphone via bluetooth with iphone app written in objective-C. I was inspired by this plugin to cordova: github.com/don/cordova-plugin-ble-central

by changing the part related to scanning: https://github.com/don/cordova-plugin-ble-central/blob/master/src/ios/BLECentralPlugin.m#L235

As per the documentation:https://developer.apple.com/library/prerelease/ios/documentation/CoreBluetooth/Reference/CBCentralManager_Class/index.html#//apple_ref/occ/instm/CBCentralManager/scanForPeripheralsWithServices:options:

you can not set any parameter to retrieve all devices with Bluetooth turned on in the vicinity, but this does not work.

Does anyone know how to fix?

1 Answers1

0

A Bluetooth LE scan won't find the another phone, unless that phone is advertising a Bluetooth LE service.

You can use LightBlue on one phone to create a peripheral offering a serivce. Use the "+" button on the top right and create a virtual peripheral.

Use the other phone, run an app with the Cordova BLE plugin and scan for devices.

ble.scan([], 5, onDiscoverDevice, failure);

onDiscoverDevice will be called every time a peripheral is discovered.

var onDiscoverDevice = function(peripheral) {
    console.log(JSON.stringify(peripheral, null, 2));
}
doncoleman
  • 2,283
  • 16
  • 15
  • hello and thank you for the answer. but it is possible that IOS does not allow them to run a scan of bluetooth devices around? (Such as Android) – Vincenzo Luongo Feb 18 '16 at 09:48
  • The user must have Bluetooth turned on. The user must grant the iOS app permission to scan for Bluetooth devices. When the phone is scanning, the Bluetooth LE devices in the area need to be advertising. If the devices aren't advertising, the scan won't find anything. – doncoleman Feb 22 '16 at 17:29