darryncampbell / darryncampbell-cordova-plugin-intent

General purpose intent shim layer for cordova appliations on Android. Handles various techniques for sending and receiving intents.
MIT License
86 stars 130 forks source link

Document the sendResult() function #96

Closed zbynekstara closed 4 years ago

zbynekstara commented 4 years ago

The sendResult() function is used in the example app (https://github.com/darryncampbell/plugin-intent-api-exerciser/blob/master/www/js/index.js), but is not documented in the readme file. The example is taken from the sample app.

darryncampbell commented 4 years ago

Thank you for the contribution, merging...

zbynekstara commented 4 years ago

@darryncampbell When sendResult is called with no arguments or only with one object, Cordova throws the following error:

jQuery.Deferred exception: Wrong type for parameter "callback" of IntentShim.sendResult: Expected Function, but got Undefined. TypeError: Wrong type for parameter "callback" of IntentShim.sendResult: Expected Function, but got Undefined.
        at Object.checkArgs
        at IntentShim.sendResult
        ...

I wasn't too sure what the callback argument was for, so I didn't include it in the example, but now I realize that if someone copy-pastes the sample code, their program will not run. Should I make a new PR with an empty function in the example and mention that both arguments need to be provided? Like this:

window.plugins.intentShim.sendResult(
    {
        extras: {
            'Test Intent': 'Successfully sent',
            'Test Intent int': 42,
            'Test Intent bool': true,
            'Test Intent double': parseFloat("142.12")
        }
    },
    function() {

    }
);