我正在使用smsCordova插件从我的离子应用程序发送短信但收到“未定义短信”的错误。 我在$ ionicPlatform.ready()函数中使用了cordovaSms插件。
这是我用来发送短信的代码: -
//use verifyNumber service
verifyNumberService.verify()
.then(
function (result) {
if (result == "Successfully data save...") {
//alert and navigate to profile Info state
$ionicPopup.alert({
title: 'Registered',
template: 'Thanks For Signup'
});
$ionicPlatform.ready(function() {
alert("in device ready function")
sendOtp();
});
$state.go('profileInfo');
}
这是sendOtp()的函数: -
function sendOtp() {
alert("inside send otp");
$cordovaSms
.send('+919765293765', "Hi there",{})
.then(function () {
// Success! SMS was sent
alert("success")
console.log('Success');
}, function (error) {
// An error occurred
alert("error");
console.log(error);
});//then
alert("send otp");
}
答案 0 :(得分:0)
Azhar Khan, 如果我们想在cordova中使用send sms请求,那么 1.我们需要在你的app中安装这个插件:
cordova plugin add https://github.com/cordova-sms/cordova-sms-plugin.git
2.需要在Controler函数中添加该插件实例($ cordovaSms):
.controller('ThisCtrl', function($cordovaSms) {
});
document.addEventListener(" deviceready",function(){
$cordovaSms.send('mobile_number', 'SMS Message', options)
.then(function() {
alert(SMS sent )
}, function(error) {
alert(Problem in sending SMS)
});
});
这就是我们所需要的所有发送短信到任何离子数字 有一个快乐的代码日。