首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用cordova插件检测OTP

问如何使用cordova插件检测OTP
EN

Stack Overflow用户
提问于 2016-09-22 17:31:08
回答 1查看 3K关注 0票数 2

我已经用过这个插件“Phonegap-SMS-reception plugin”,但我不能从命令提示符或手动安装它。除此之外,我找不到任何其他插件来检测动态口令,并从混合移动应用程序的短信中获取数据

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-30 17:37:31

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

代码语言:javascript
复制
<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>

请确保应用程序已在棉花糖中授予了读取sms权限。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39635282

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档