-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathindex.android.js
More file actions
34 lines (32 loc) · 1.24 KB
/
index.android.js
File metadata and controls
34 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function send(numbers, message, subject) {
return new Promise(function (resolve, reject) {
if(Array.isArray(numbers)){
const numList = numbers.map((n,i)=>{
if(i === numbers.length - 1){
return n;
}else{
return n+','
}
}).join("");
try {
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
intent.setData(android.net.Uri.parse("smsto:" + numList));
intent.putExtra("sms_body", message);
intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
com.tns.NativeScriptApplication.getInstance().startActivity(intent);
console.log("Message Sent.");
resolve({
response: "sent",
message: "Message sent."
});
} catch(ex) {
console.log("Something Failed.");
reject(Error("Message send failed."));
}
} else {
console.log("Something Failed.");
reject(Error("Message send failed."));
}
});
}
exports.send = send;