I am working with ionic framework and my aim here is to get device uuid and send it as sms to a phone number.
I am using cordova device plugin to get device uuid but don't know how to send it as sms.
angular.module('starter.controllers', [])
.controller('AppCtrl', function() {})
.controller('DeviceCtrl', function($ionicPlatform, $scope, $cordovaDevice) {
$ionicPlatform.ready(function() {
$scope.$apply(function() {
// sometimes binding does not work! :/
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
// getting device infor from $cordovaDevice
var device = $cordovaDevice.getDevice();
$scope.manufacturer = device.manufacturer;
$scope.model = device.model;
$scope.platform = device.platform;
$scope.uuid = device.uuid;
var deviceid=device.uuid;
//pass the deviceid
sendsms(deviceid);
function sendsms(deviceid){
var app = {
sendSms: function() {
var number ="mobile no";
var message ="deviceid is"+deviceid;
alert(number);
alert(message);`
//CONFIGURATION
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
}
};
var success = function () { alert('Message sent successfully'); };
var error = function (e) { alert('Message Failed:' + e); };
sms.send(number, message, options, success, error);
}
};
}
});
});
})
<ion-view view-title="Device Information">
<ion-content>
<div class="card">
<div class="item item-divider">
Your device information!
</div>
<div class="item item-text-wrap">
<ul class="list">
<li class="item">
Manufacturer : {{manufacturer}}
</li>
<li class="item">
Model : {{model}}
</li>
<li class="item">
Platform : {{platform}}
</li>
<li class="item">
UUID : {{uuid}}
</li>
</ul>
</div>
<div class="item item-divider text-right">
</div>
</div>
</ion-content>
</ion-view>