I am creating a mobile (iphone/android) application using appcelerator titanium. Is there any way I can make the app send sms to any given number with appcelerator titanium?
7 Answers
1
votes
If you don't want to pay, here's an SMS module for iOS:
http://developer.appcelerator.com/question/97961/ios-sms-dialog-module
You'll need to follow his guides, but you should be able to get it to work. For android, you can simply call a URL with "sms://"+phoneNumber or something similar.
1
votes
1
votes
There is a function you can use to send SMS :
var SMS_SENT = -1,
SMS_NOT_SENT = 0;
/**
* Open an SMS dialog with the given message.
* If the SMS is sent, run the onSuccess callback.
*
* @message {text} the text you want to send
* @callback {function} the funciton you want to run on success
**/
function openSmsDialog(message, onSuccess) {
if (Ti.Platform.osname === 'android') {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
type: 'vnd.android-dir/mms-sms'
});
intent.putExtra('sms_body', message);
var _onClose = function(activityResult) {
if (activityResult.resultCode === SMS_SENT && onSuccess) {
onSuccess();
}
};
Ti.Android.currentActivity.startActivityForResult(intent, _onClose);
} else {
var smsModule = require("com.omorandi");
var smsDialog = smsModule.createSMSDialog({
messageBody: message
});
if (onSuccess) {
smsDialog.addEventListener('complete', onSuccess);
}
}
}
To make this code work on iOS, you have to use the com.omorandi module. For android, you don't need any module.
0
votes
0
votes
0
votes
just found your question while searching google for something else. so I figured I'll answer in case someone encounter this Q in the future.
there's a module in the Appcelerator Marketplace for sending an SMS message: https://marketplace.appcelerator.com/apps/6521?1019589994