Search code examples
cordovacordova-plugins

can not get the cordova-sms-plugin to work


I'm trying to install a cordova sms plugin. and I'm doing like te following steps:

  1. created a new project by phonegap create smsProj
  2. added android platform by phonegap platform add android
  3. installed the plugin by cordova plugin add com.jsmobile.plugins.sms
  4. then I tried to check if SMS is available by:

try {
  alert( SMS == undefined );
} catch (e) {
  alert('catch: SMS is not available')
}

I'm checking this after deviceReady event, in Android, latest cordova and of course by building and installing in real device. but I'm getting the catch alert every time.
What I am doing wrong?


Solution

  • you need to add this line into your config.xml file:

    <gap:plugin name="com.rjfun.cordova.sms" source="npm"/>
    

    this configuration must be added programmatically since you've installed the plugin using CLI, but in this case it's not what I expected. I figured it out opening the apk file content and checking cordova plugins JS file.