Wolrab Wolrab - 4 months ago 56
Android Question

Ionic & Cordova SMS Plugin

I'm trying to add the SMS cordova plugin to my ionic application but I'm failing miserably.

I've no idea how to inject the plugin or use it the documentation seems to be more phonegapp orientated.

I've got the following:


cordova plugin add

My view

<button ng-click="send()">Test</button>

My Controller

angular.module('starter.controllers', [])

.controller('DashCtrl', function($scope, $http, $state, $cordovaSms) {

$scope.send = function(){

.send('phonenumber', 'SMS content')
.then(function() {
// Success! SMS was sent
}, function(error) {
// An error occurred



I get the following error:

ionic.bundle.js:26794 Error: [$injector:unpr] Unknown provider:

$cordovaSmsProvider <- $cordovaSms <- DashCtrl


I think it's a casing issue. Are you using ionic-native yet? If not, start there. bower install ionic-native --save bower uninstall ngCordova --save

Then replace ngCordova with ionic.native in your module dependencies.

Here is working code from one of my projects...

   .controller('RosterCtrl', function ($cordovaSMS, ...

   // snip ....

    $cordovaSMS.send(phone, message)
      .then(function () {
        $log.log('Message sent.');