randdusing / cordova-plugin-bluetoothle

Bluetooth Low Energy Phonegap Plugin
804 stars 353 forks source link

startScan() method returns nothing (success or error callbacks) on IOS #309

Open fabLouis opened 8 years ago

fabLouis commented 8 years ago

Hello,

When I call startScan() method (with {} for params), the success or error callbacks are not raised only on iOS, on Android it's work well. Why?

My environment:

$ cordova -v
6.1.1
$ ionic platform
Installed platforms:
  android 5.1.1
  ios 4.1.1
$ ionic plugin list
com.verso.cordova.clipboard 0.1.0 "Clipboard"
cordova-plugin-bluetoothle 4.2.0 "Bluetooth LE"
cordova-plugin-camera 2.2.0 "Camera"
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-email-composer 0.8.3 "EmailComposer"
cordova-plugin-file 4.2.0 "File"
cordova-plugin-file-transfer 1.5.1 "File Transfer"
cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.4.0 "InAppBrowser"
cordova-plugin-splashscreen 4.0.0 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
ionic-plugin-keyboard 2.2.0 "Keyboard"
phonegap-plugin-push 1.7.0 "PushPlugin"

The (basic) code:

this.bleComponent.startScan(
    function(results) {
        console.debug('startScan > success: ' + JSON.stringify(results));
    }, 
    function(err) {
        console.error('startScan > error: ' + JSON.stringify(err));
    },
    {}
);
...
setTimeout(function () {
    this.stopScan();
}, this.scanningDelay);

Tested on iPhone 5c (iOS 9.3.2) with severals estimotes.

Thanks for your help

randdusing commented 8 years ago

Can you post the source for bleComponent?

fabLouis commented 8 years ago

I think it's not important because the bleComponent is a wrapper class for the opportunity to easily change (in case) the BLE plugin.

For the exemple for the bleComponent.startScan() method:

public startScan(successCallback, errorCallback, params) {
    this.bluetoothle.startScan(successCallback, errorCallback, params);
}
randdusing commented 8 years ago

Maybe try removing and readding the plugin. Also the this. in this.bluetoothlecould potentially be causing an issue.

fabLouis commented 8 years ago

Same result Rand. About the this.bluetoothle, the this. is here because the language is TypeScript.

randdusing commented 8 years ago

Do you have Ionic installed? You could try using the example in https://github.com/randdusing/ng-cordova-bluetoothle. If even that doesn't work, it may be device related.