1

卡住了SMSComposer插件。我已按照所有步骤将密钥添加到插件列表并下载文件。这是来自 github 的最新版本,它让我感到困惑。我更了解旧的。如何指定toRecipientsbody

function SMSComposer()
{
    this.resultCallback = null;
}

SMSComposer.ComposeResultType =
{
Cancelled:0,
Sent:1,
Failed:2,
NotSent:3
}

SMSComposer.prototype.showSMSComposer = function(toRecipients, body)
{

    var args = {};

    if(toRecipients)
        args.toRecipients = toRecipients;

    if(body)
        args.body = body;

    Cordova.exec("SMSComposer.showSMSComposer",args);
}

SMSComposer.prototype.showSMSComposerWithCB = function(cbFunction,toRecipients,body)
{
    this.resultCallback = cbFunction;
    this.showSMSComposer.apply(this,[toRecipients,body]);
}

SMSComposer.prototype._didFinishWithResult = function(res)
{
    this.resultCallback(res);
}

Cordova.addConstructor(function() {

                       if(!window.plugins)  {
                       window.plugins = {};
                       }
                       window.plugins.smsComposer = new SMSComposer();
                       });

.

    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
                </div <center><button onclick="cordova.exec(null,null, 'SMSComposer','showSMSComposer',[args])">Compose SMS</button></center>

                >
            </div>
            <script type="text/javascript" src="cordova-2.2.0.js"></script>
            <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript" charset="utf-8" src="SMSComposer.js"></script>

            <script type="text/javascript">
                app.initialize();

                var args;

                // cordova.exec(null,null, 'SMSComposer','showSMSComposer',[args]);



                </script>

            </body>
</html>

编辑:当我按下button. 控制台中没有错误消息。

4

2 回答 2

3

试试这个: https ://github.com/wesson818/SMSPluginForCordova2.3.0 您可以在 Android 原生消息应用程序中传递消息正文并选择收件人。

于 2013-02-07T05:18:10.993 回答
0

@ PA Hemingstam 如果您在 SMSComposer.js 文件中将“Cordova”替换为“cordova”,那么它将起作用。:)

于 2013-01-16T05:52:28.700 回答