I believe Don's issue is directly related to my recent change in cordova-js [#1], for which there is a reversing pull request [#2]
The expectation of what a NO_RESULT meant was not documented, and my change made it so it called the error callback. I will be accepting the pull request today ( and adding a comment to clearly state that NO_RESULT is NOT an error, and does NOT call the error handler. ) Don, can you try changing your cordova.js file? ( directly in the platforms/ios/ folder and seeing if you still see the issue) You can mimic this change: [3] [1] https://github.com/apache/cordova-js/commit/9eb4f7faf607ae22fb8b6ee31d24fd622dbaf64c [2] https://github.com/apache/cordova-js/pull/98 [3] https://github.com/apache/cordova-ios/pull/123/files @purplecabbage risingj.com On Thu, Jan 8, 2015 at 12:14 PM, Andrew Grieve <[email protected]> wrote: > You need to call setKeepCallbackAsBool:TRUE to be able to send subsequent > callbacks. If you just don't send a result though, it'll stay waiting. You > can remove the NO_RESULT. > > > On Thu, Jan 8, 2015 at 2:02 PM, Don Coleman <[email protected]> wrote: > > > I know this is an old thread but I'm seeing problems with this in my > > Bluetooth plugins now that people are upgrading. > > > > Cordova 4.1.2 with iOS 3.7.0 is broken. NO_RESULT calls the failure > > callback. > > After downgrading to Cordova 4.0.0 with iOS 3.6.0 the plugin works as > > expected. > > > > I use NO_RESULT since I hold onto command.callbackId when a Cordova > method > > is called and call the callback later from an iOS delegate callback. > > > > > > > https://github.com/don/BluetoothSerial/blob/master/src/ios/MEGBluetoothSerial.m#L148 > > > > > > I was under the impression that i needed to call [pluginResult > > setKeepCallbackAsBool:TRUE]; to keep the callback. Is this false? > > > > Can I just remove all the iOS calls that return NO_RESULT? > > > > > > > > > > On Tue, Nov 25, 2014 at 2:15 PM, Andrew Grieve <[email protected]> > > wrote: > > > > > My guess as to why NO_RESULT exists, is because on Android, plugin > > > functions used to *have* to return a PluginResult. The only way to not > > have > > > this reach JS was to set it to NO_RESULT. > > > > > > I don't actually see a use-case to ever send a NO_RESULT now... > > > > > > But, I think your pseudocode seems correct in the issue. > > > > > > On Mon, Nov 24, 2014 at 5:59 PM, Shazron <[email protected]> wrote: > > > > > > > https://issues.apache.org/jira/browse/CB-8063 > > > > > > > > What I am discussing requires a change in cordova.js that will affect > > > > all platforms. > > > > > > > > > > > > NO_RESULT (integer:0) is treated as success by iOS [1] and Android > [2]. > > > > > > > > On Android, NO_RESULT is not processed on the JS layer if > keepCallback > > > > is true [3] > > > > while on iOS it is always sent. > > > > > > > > In cordova.js, lines 203-207 [4] seem to imply that you would only > > > > call the success callback if the status was OK. However, the logic in > > > > it, would send a failure callback for NO_RESULT (which is a > > > > "success"). > > > > > > > > I believe the intent was this pseudo-code: > > > > > > > > ``` > > > > if (success) { > > > > if (status is OK) { > > > > // call success callback > > > > } else { > > > > // do nothing, NO_RESULT (success) > > > > } > > > > } else { > > > > // call fail callback > > > > } > > > > > > > > ``` > > > > > > > > QUESTION: > > > > However, I think if it was NO_RESULT, shouldn't it call the success > > > > callback anyway since it was a success? Or is NO_RESULT expected to > > > > not call any callback? I don't know the answer to this, nor could I > > > > find any docs to suggest that is the way it is. I think we need to be > > > > consistent on the behaviour of the NO_RESULT status code, with > minimal > > > > impact to existing plugin code. > > > > > > > > > > > > --------- > > > > > > > > [1] > > > > > > > > > > https://github.com/apache/cordova-js/blob/f6db82f4c737bd96a14fbc77e0a67b6d799ec06a/src/ios/exec.js#L308 > > > > [2] > > > > > > > > > > https://github.com/apache/cordova-android/blob/fbeb379f1b2102d9d0739f92340c932bdc47873b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java#L509 > > > > [3] > > > > > > > > > > https://github.com/apache/cordova-android/blob/fbeb379f1b2102d9d0739f92340c932bdc47873b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java#L238-L243 > > > > [4] > > > > > > > > > > https://github.com/apache/cordova-js/blob/1fc2526faa6197e1637ecb48ebe0f876f008ba0f/src/cordova.js#L203-L207 > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [email protected] > > > > For additional commands, e-mail: [email protected] > > > > > > > > > > > > > >
