Skip to content

Instantly share code, notes, and snippets.

@rastalamm
Created August 12, 2015 19:53
Show Gist options
  • Save rastalamm/3517e26193cd75ec0fb0 to your computer and use it in GitHub Desktop.
Save rastalamm/3517e26193cd75ec0fb0 to your computer and use it in GitHub Desktop.
Implementation of Cordova SMS
angular.module('starter')
.controller('SmsController', ['$ionicPlatform', '$scope', '$cordovaSms',
function($ionicPlatform, $scope, $cordovaSms) {
console.log('inside');
$ionicPlatform.ready(function (){
$scope.sendSms = function (){
var number = '15169650711';
var message = 'Hello World';
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without open any other app
}
};
$cordovaSms
.send(number, message, options)
.then(function() {
// Success! SMS was sent
alert('success');
$scope.success = 'Success'
})
.catch(function(error) {
// An error occurred
alert(error);
$scope.fail = 'fail ' + error
});
}
})
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment