Use cordova SMS plugin correctly



  • Hello everyone,
    I’m trying to use this plugin: https://github.com/floatinghotpot/cordova-plugin-sms#readme
    I added the plugin using

    cordova plugin add cordova-plugin-sms
    

    And updated my Formulaire.vue like this:

    <template>
      <q-page padding>
        <p>
          FORMULAIRE
        </p>
        <q-btn
          color="primary"
          icon="question_answer"
          label="Vérifier en central"
          @click="sendSMS ()" />
      </q-page>
    </template>
    
    <script>
    export default {
      name: 'Formulaire',
      data () {
        return {
          SMStext: 'TEST SMS'
        }
      },
      methods: {
        initApp () {
          if (!SMS) {
            alert('SMS plugin not ready')
          }
        },
        sendSMS () {
          var sendto = '+123456'
          var textmsg = 'TEST'
          if (sendto.indexOf(';') >= 0) {
            sendto = sendto.split(';')
            for (var i in sendto) {
              sendto[i] = sendto[i].trim()
            }
          }
          if (SMS) {
            SMS.sendSMS (sendto, textmsg, function () { }, function (str) { alert (str) })
          }
        }
      },
      created () {
        if ((/(ipad|iphone|ipod|android)/i.test (navigator.userAgent))) {
          window.addEventListener ('deviceready', this.initApp, false)
        } else {
          // updateStatus ('need run on mobile device for full functionalities.')
        }
      }
    }
    </script>
    

    But when I run

    quasar dev -m cordova -T android
    

    I have this error:

    /home/cesar/projets/quasar/client_sms_referendum/src/pages/Formulaire.vue
      24:12  error  'SMS' is not defined  no-undef
      37:11  error  'SMS' is not defined  no-undef
      38:9   error  'SMS' is not defined  no-undef
    

    I know I didn’t defined ‘SMS’ but I checked the example given on github and I really don’t see how I can solve it…
    Thanks for your help 🙂



  • I managed to buldi my apk after editing my .eslintrc.js file:

    'no-undef': 'off'
    

    But I think it’s not the correct way to do it.


Log in to reply