多个数字的 sendsms() 中的 cordova 错误,"Message Failed:error"
cordova error in sendsms() for multiple numbers ,"Message Failed:error"
在 cordova 中,在 github.com/cordova-sms/cordova-sms-plugin/issues/8 中我们可以使用多个数字,但我有这个错误,
sendSms2: function (id) {
try {
var number = "'"+window.localStorage.getItem("NUMBERS") + "'";
var message = window.localStorage.getItem("TEXT");
alert(number + " : " + message);
console.log("number=" + number + ", message= " + message);
//CONFIGURATION
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: ''
}
};
var success = function () {
alert('Message sent successfully for:' + id);
};
var error = function (e) {
alert('Message Failed:' + e);
};
sms.send('9133333333,9122222222', message, options, success, error);
} catch (e) {
alert(e);
}
},
但我 "Message Failed:error" 处于警报状态,
它适用于一个,但不适用于更多,
这是不可能的,
使用for循环
sendSms2: function (id) {
try {
var busyFlag = 0;
if (!busyFlag) {
var number = '9133333333,9122222222';
var numbers = number.split(",");
var message = 'test';
alert(number + " : " + message);
//CONFIGURATION
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: '' // send SMS without open any other app
}
};
var success = function () {
alert('Message sent successfully for:' + id);
};
var error = function (e) {
alert('Message Failed:' + e);
};
for (var i = 0; i < numbers.length; i++) {
busyFlag = 1;
sms.send(numbers[i], message, options, success, error);
}
busyFlag = 0;
}
} catch (e) {
alert(e);
}
}
在 cordova 中,在 github.com/cordova-sms/cordova-sms-plugin/issues/8 中我们可以使用多个数字,但我有这个错误,
sendSms2: function (id) {
try {
var number = "'"+window.localStorage.getItem("NUMBERS") + "'";
var message = window.localStorage.getItem("TEXT");
alert(number + " : " + message);
console.log("number=" + number + ", message= " + message);
//CONFIGURATION
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: ''
}
};
var success = function () {
alert('Message sent successfully for:' + id);
};
var error = function (e) {
alert('Message Failed:' + e);
};
sms.send('9133333333,9122222222', message, options, success, error);
} catch (e) {
alert(e);
}
},
但我 "Message Failed:error" 处于警报状态,
它适用于一个,但不适用于更多,
这是不可能的,
使用for循环
sendSms2: function (id) {
try {
var busyFlag = 0;
if (!busyFlag) {
var number = '9133333333,9122222222';
var numbers = number.split(",");
var message = 'test';
alert(number + " : " + message);
//CONFIGURATION
var options = {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: '' // send SMS without open any other app
}
};
var success = function () {
alert('Message sent successfully for:' + id);
};
var error = function (e) {
alert('Message Failed:' + e);
};
for (var i = 0; i < numbers.length; i++) {
busyFlag = 1;
sms.send(numbers[i], message, options, success, error);
}
busyFlag = 0;
}
} catch (e) {
alert(e);
}
}