Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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
ionic firebase phoneAuth在ios上不带recaptcha_Firebase_Ionic4_Recaptcha - Fatal编程技术网

ionic firebase phoneAuth在ios上不带recaptcha

ionic firebase phoneAuth在ios上不带recaptcha,firebase,ionic4,recaptcha,Firebase,Ionic4,Recaptcha,我有一个ionic应用程序,我使用firebase电话验证,它使用recaptcha。它在android上运行良好,但在ios上抛出错误,称recaptcha只能在http环境中运行。我想知道是否有一种方法可以在不使用recaptcha的情况下执行firebase电话验证 this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container',{ 'size': 'invisible

我有一个ionic应用程序,我使用firebase电话验证,它使用recaptcha。它在android上运行良好,但在ios上抛出错误,称recaptcha只能在http环境中运行。我想知道是否有一种方法可以在不使用recaptcha的情况下执行firebase电话验证

    this.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container',{
      'size': 'invisible'
    });


              let appVerifier = this.recaptchaVerifier;
              this.appService.sendPhoneVerification(phoneNumber,appVerifier) 
              .then(confirmationResult => {
                   //do something
                })

Ios抛出错误“RECAPTCHA只能在HTTP/HTTPS环境中运行”

这就是我如何解决我的问题“RECAPTCHA只能在HTTP/HTTPS环境中运行”

  • 安装Firebase插件:
  • 将其添加到app.module.ts
  • 进行平台检查:检查其iOS是否可用

    if(this.plt.is('ios')){
    //这里是ios代码
    }否则{
    //这里是安卓
    }

  • 现在添加以下代码(iOS平台)向用户发送验证码sms以验证电话号码。将插件注入构造函数。创建一个变量来分配promise中的数据。电话号码应为国家代码+号码。示例“+1999999999”

    公共登录用户(phoneNum){
    这个.firebase.verifyPhoneNumber(phoneNum).then((vdata)=>{
    this.refConfirm=vdata;
    //您可以将此人重定向到验证页面或向其显示警报
    输入验证码。
    });
    }

  • 现在,创建一个令牌,使用firebase验证并使用凭据登录用户

    公共验证电话号码(phoneNumber){
    让tokenPhone=firebase.auth.PhoneAuthProvider.credential(this.refConfirm,
    电话号码);
    firebase.auth().signInWithCredential(令牌电话)。然后((验证数据)=>{
    //无论您想在这里做什么,或者将用户重定向到主页。
    });
    }

  • 在Firebase上生成GoogleService.plist并添加到项目根目录

  • 您必须添加反向的客户端id,而不是普通的客户端id

  • 我就是这样解决的

  • 那么...怎么样