Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when unsubscribing from BLE.startScanWithOptions() #943

Closed
tkem opened this issue Jan 8, 2017 · 0 comments
Closed

Error when unsubscribing from BLE.startScanWithOptions() #943

tkem opened this issue Jan 8, 2017 · 0 comments

Comments

@tkem
Copy link
Contributor

tkem commented Jan 8, 2017

When unsubscribing from an Observable returned by BLE.startScanWithOptions(), which should implicitly call BLE.stopScan(), I get the following error on Android:

Error: Error: Uncaught (in promise): TypeError: callback.success.apply is not a function
TypeError: callback.success.apply is not a function
    at Object.callbackFromNative (cordova.js:293)

Doing some debugging in Chrome, it looks like cordova.callbacks[callbackId] contains

"{"success":[],"fail":{"reportDuplicates":true}}"

which happen to be the arguments as passed to startScanWithOptions(), and not the success/failure callbacks for BLE.stopScan(), as apparently expected.

Having a look at the BLE plugin source (https://github.com/driftyco/ionic-native/blob/master/src/plugins/ble.ts#L218) , the following seems suspicious:

 @Cordova({
    observable: true,
    clearFunction: 'stopScan',
    clearWithArgs: true
  })
static startScanWithOptions(services: string[], options: {reportDuplicates?: boolean} | any): Observable<any> { return; }

AFAIK, clearWithArgs: true would pass the arguments of the decorated function to the clearFunction, too. However, BLE.stopScan() does not expect any arguments (except for success/failure callbacks), so this is likely the cause for this.

Note that the same (clearWithArgs: true) also applies to BLE.startScan(), but I'm not using this and so I cannot verify that the same error occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant