2013-01-15 68 views
1

插入SMSComposer插件。我已經按照所有步驟將鍵添加到插件列表並下載文件。這是來自github的最新版本,它讓我感到困惑。我更瞭解舊的。我如何指定toRecipientsbodyPhonegap SMSComposer混淆

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。控制檯中沒有錯誤信息。

回答

0

@ P A Hemingstam 如果用SMSComposer.js文件中的「cordova」替換「Cordova」,那麼它將起作用。 :)