RyanP13
RyanP13

Reputation: 7743

Cordova Android SMS plugin does not fire success or error callbacks

I am using the following plugin for Cordova with Android:

https://github.com/aharris88/phonegap-sms-plugin

I can validate that the SMS application opens and that a message is sent but the JS success or error callbacks are never fired.

The code is implemented as per the plugin so I cannot think why this is not working to trigger the callbacks. I am using it with Cordova 2.9 although re-written for 3.0 the plugin is compatible with a few modifications as follows.

In the sms JAVA file I had to update the dependencies like so:

import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaPlugin;
import org.apache.cordova.api.PluginResult;

In the JS file i removed the following line:

module.exports = sms;

And just hook onto the sms global variable for now which is working.

My JS to call the SMS function follows the same as in the example provided:

        var number = '123456789';
        var message = 'foo!';
        var intent = "INTENT"; //leave empty for sending sms using default intent
        var success = function() {
            $.magnificPopup.close();
        };
        var error = function(e) {
            alert('Message Failed:' + e);
        };
        sms.send(number, message, intent, success, error);

UPDATE

If I remove the INTENT then the SMS is fired with the default SMS application automatically and things work as expected.

However, is there a way to trigger a JS call back when the message is sent from the SMS application?

Upvotes: 0

Views: 1239

Answers (1)

Hasanavi
Hasanavi

Reputation: 8625

The updated version should resolve your issue.

https://github.com/aharris88/phonegap-sms-plugin

Upvotes: 0

Related Questions