4

我正在使用 appcelerator Titan 创建一个移动(iphone/android)应用程序。有什么方法可以让应用程序使用 appcelerator 钛向任何给定号码发送短信?

4

7 回答 7

1

有一个功能可以用来发送短信:

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);
        }
    }
}

要使此代码在 iOS 上运行,您必须使用com.omorandi模块。对于 android,您不需要任何模块。

于 2013-09-20T06:16:51.370 回答
1

如果您不想付款,这里有一个适用于 iOS 的 SMS 模块:

http://developer.appcelerator.com/question/97961/ios-sms-dialog-module

你需要遵循他的指南,但你应该能够让它发挥作用。对于 android,您可以简单地调用带有“sms://”+phoneNumber 或类似名称的 URL。

于 2011-06-07T13:34:08.557 回答
1

这里有一些 Titanium 模块:https ://marketplace.appcelerator.com/listing?1201386205&q=sms

于 2012-04-25T16:43:13.620 回答
0

这是一个很棒的模块。

只支持安卓。无需 usr 交互会自动发送短信

https://github.com/omorandi/TiAndroidSMS

于 2013-04-01T13:06:30.647 回答
0

刚刚在谷歌搜索其他东西时发现了你的问题。所以我想我会回答,以防将来有人遇到这个Q。

Appcelerator Marketplace 中有一个用于发送 SMS 消息的模块:https ://marketplace.appcelerator.com/apps/6521?1019589994

于 2013-09-20T05:40:37.187 回答
0

Appcelerator 有一组模块,如果您是其中一个合作伙伴计划的成员,您可以使用这些模块。它包括一个短信模块:

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

于 2011-06-07T10:31:46.227 回答
0

如果您只想使用您自己的信息打开 SMS 应用程序,您可以使用以下内容:

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

请注意,数字和正文都是可选的。

于 2017-06-07T14:46:07.157 回答