2016-09-22 67 views
1

我已经使用这个插件“Phonegap-SMS-reception-plugin”,但我无法从命令提示符或手动安装它。 除此之外,我找不到任何其他插件用于检测OTP并从混合移动应用程序的短信中获取数据如何检测使用科尔多瓦插件的OTP

回答

3

该插件中缺少一些文件。使用此cordova-plugin-sms

<script type="text/javascript"> 

    var body = ""; 
    var address = ""; 

    $(document).ready(function() { 

     if((/(ipad|iphone|ipod|android)/i.test(navigator.userAgent))) { 
      document.addEventListener('deviceready', initApp, false); 
     } else { 
      alert('need run on mobile device for full functionalities.'); 
     } 

    }); 




      function startWatch() { // start listening incoming sms 
       if(SMS) SMS.startWatch(function(){ 
        alert('watching', 'watching started'); 
       }, function(){ 
        alert('failed to start watching'); 
       }); 
      } 


      function stopWatch() { // stop listening incoming sms 
       if(SMS) SMS.stopWatch(function(){ 
        update('watching', 'watching stopped'); 
       }, function(){ 
        updateStatus('failed to stop watching'); 
       }); 

      } 




     function initApp() { 
     if (! SMS) { alert('SMS plugin not ready'); return; } 


     document.addEventListener('onSMSArrive', function(e){ 
      var sms = e.data; 

      body = sms.body; 
      address = sms.address; 

     }); 
    } 


    </script> 

确保应用程序已经阅读棉花糖授予短信的权限。