Created
August 12, 2015 19:53
-
-
Save rastalamm/3517e26193cd75ec0fb0 to your computer and use it in GitHub Desktop.
Implementation of Cordova SMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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