开发者

Appcelerator titanium - send sms

开发者 https://www.devze.com 2023-03-11 03:46 出处:网络
I am creating a mobile (iphone/android) application using appcelerator titani开发者_Python百科um. Is there any way I can make the app send sms to any given number with appcelerator titanium?If you don

I am creating a mobile (iphone/android) application using appcelerator titani开发者_Python百科um. Is there any way I can make the app send sms to any given number with appcelerator titanium?


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.


Here's a few Titanium modules: https://marketplace.appcelerator.com/listing?1201386205&q=sms


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.


Appcelerator have a set of modules that you can use if you are a member of one of their partner programmes. It includes an SMS module:

http://www.appcelerator.com/products/titaniumplus/


Here is a great module for this.

Only support Android. Will send sms automatically without usr interaction

https://github.com/omorandi/TiAndroidSMS


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


If you wish to just open the SMS app with your own information, you can use the following:

Ti.Platform.openURL("sms:01234567891&body=hey");

Note both the number and body is optional.

0

精彩评论

暂无评论...
验证码 换一张
取 消