Phonegap SMSComposer混乱

时间:2013-01-15 03:56:32

标签: ios cordova

坚持使用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时没有反应。控制台中没有错误消息。

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:0)

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