Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native React本机firebase电话身份验证_React Native_Authentication_Firebase Authentication_Expo_React Native Firebase - Fatal编程技术网

React native React本机firebase电话身份验证

React native React本机firebase电话身份验证,react-native,authentication,firebase-authentication,expo,react-native-firebase,React Native,Authentication,Firebase Authentication,Expo,React Native Firebase,我正在尝试使用expo和firebase身份验证构建React本机应用程序。电子邮件/密码身份验证工作正常,但由于applicationVerifier,电话号码身份验证失败。 我曾尝试使用“react native firebase”,但这也不起作用,并给出了错误 [错误:仅在具有DOM支持的浏览器HTTP/HTTPS环境中支持RecaptchaVerifier。] 谢谢。您需要生成.html文件并将此代码放入 <!DOCTYPE html> <html lang="ru"&

我正在尝试使用expo和firebase身份验证构建React本机应用程序。电子邮件/密码身份验证工作正常,但由于applicationVerifier,电话号码身份验证失败。 我曾尝试使用“react native firebase”,但这也不起作用,并给出了错误

[错误:仅在具有DOM支持的浏览器HTTP/HTTPS环境中支持RecaptchaVerifier。]


谢谢。

您需要生成.html文件并将此代码放入

<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>Entering captcha</title>
</head>
<body>
    <p style="text-align: center; font-size: 1.2em;">Please, enter captcha for continue<p/>
    <button id="continue-btn" style="display:none">Continue to app</button>

    <script src="https://www.gstatic.com/firebasejs/5.10.1/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/5.10.1/firebase-auth.js"></script>
    <script>
      // Initialize Firebase
      var config = {
        apiKey: "AIzaSyCy6HyqIV5Q_A5lllIxZgePSmKq-Q8eqiw",
      authDomain: "onsignledemo.firebaseapp.com",
      databaseURL: "https://onsignledemo.firebaseio.com",
      projectId: "onsignledemo",
      storageBucket: "onsignledemo.appspot.com",
      messagingSenderId: "223114260821"
      };
      firebase.initializeApp(config);
    </script>    <script>
        function getToken(callback) {
            var container = document.createElement('div');
            container.id = 'captcha';
            document.body.appendChild(container);
            var captcha = new firebase.auth.RecaptchaVerifier('captcha', {
                'size': 'normal',
                'callback': function(token) {
                    callback(token);
                },
                'expired-callback': function() {
                    callback('');
                }
            });
            captcha.render().then(function() {
                captcha.verify();
            });
        }
        function sendTokenToApp(token) {
            var baseUri = decodeURIComponent(location.search.replace(/^\?appurl\=/, ''));
            const finalUrl = location.href = baseUri + '/?token=' + encodeURIComponent(token);
            const continueBtn = document.querySelector('#continue-btn');
            console.log(finalUrl);
            // continueBtn.onclick = (event)=>{
            //     window.open(finalUrl,'_blank')
            // }
            continueBtn.style.display = "block";
        }
        document.addEventListener('DOMContentLoaded', function() {
            getToken(sendTokenToApp);
        });
    </script>
</body>
</html>

输入验证码
请输入验证码以继续

继续下载应用程序 //初始化Firebase 变量配置={ apiKey:“AIzaSyCy6HyqIV5Q_A5lllIxZgePSmKq-Q8eqiw”, authDomain:“onsignledemo.firebaseapp.com”, 数据库URL:“https://onsignledemo.firebaseio.com", projectId:“onsignledemo”, storageBucket:“onsignledemo.appspot.com”, messagingSenderId:“223114260821” }; firebase.initializeApp(配置); 函数getToken(回调){ var container=document.createElement('div'); container.id='captcha'; 文件.正文.附件(容器); var captcha=new firebase.auth.RecaptchaVerifier('captcha'{ “大小”:“正常”, “回调”:函数(令牌){ 回调(令牌); }, “过期回调”:函数(){ 回调(“”); } }); captcha.render().then(函数()){ 验证码验证(); }); } 函数sendTokenToApp(令牌){ var baseUri=decodeURIComponent(location.search.replace(/^\?appurl\=/,“”)); const finalUrl=location.href=baseUri+'/?令牌='+encodeURIComponent(令牌); const continueBtn=document.querySelector(“#continue btn”); 控制台日志(finalUrl); //continueBtn.onclick=(事件)=>{ //窗口。打开(最终,“空白”) // } continueBtn.style.display=“block”; } document.addEventListener('DOMContentLoaded',function(){ getToken(sendTokenToApp); });


并将此文件放入正在运行的服务器中,加载URL,以便在发送确认码之前和验证此验证码之后发送确认码…

仅适用于iOS。不过,不会在android emulator上返回令牌。我不知道,但可能是浏览器问题?!