簡體   English   中英

如何使用cordova插件檢測OTP

[英]how to detect OTP using cordova plugin

我已經使用了此插件“ Phonegap-SMS-reception-plugin”,但無法從命令提示符或手動安裝它。 除此之外,我找不到其他任何插件來檢測OTP並從混合移動應用程序的短信中獲取數據

該插件中缺少一些文件。 使用此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>

確保該應用程序已讀取棉花糖中授予的短信權限。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM