Search code examples
javascriptcordovaphonegap-pluginsintel-xdk

How do i send a SMS using phonegap without opening the native app?


I am making an SMS app using HTML,CSS, and JAVASCRIPT on intel xdk. I have tried quite a few SMS phonegap plugins, but all open the native SMS app and the user has to click send again.

Is there anyway i can send the SMS using the above coding languages but without opening the default SMS app?

EDIT : Surprisingly, just moments after posting this question. I found this CORDOVA SMS PLUGIN I'm yet to check if it works. Meanwhile, is there any other method too?


Solution

  • I tried that plugin (https://github.com/hazems/cordova-sms-plugin) and it worked for me. I can't endorse it, but I was able to send a text message without going into the SMS app, though it does show the message in my history of messages in the SMS app.

    I just included the plugin as a third party plugin on the projects page and used this code (with a valid number in place of the Xs) :

    var mymsg = {
        phoneNumber: "XXXXXXXXXX",
        textMessage: "Testing"
    }
    
    if (typeof sms === 'undefined' || typeof sms.sendMessage !== 'function') {
        alert("No plugin");
    }
    sms.sendMessage(mymsg, function(message) {
        console.log("success: " + message);
        alert("Sent");
    }, function(error) {
        console.log("code: " + error.code + ", message: " + error.message);
        alert("Error sending");
    });