firebase.auth.RecaptchaVerifier is not a constructor error

元气小坏坏 提交于 2020-01-30 08:20:06

问题


Trying to add the Firebase script in my html, after initializing Firebase app with firebase.initializeApp(config);.

So then I have this :

 <script>

          window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', 
           {
            'size': 'invisible',
            'callback': function(response) {
            // reCAPTCHA solved, allow signInWithPhoneNumber.
            onSignInSubmit();
            }
      });

 </script>

Which provides the error :

firebase.auth.RecaptchaVerifier is not a constructor error
  1. How to solve this error (found similar questions without a direct answer)
  2. How to proceed from here with the full flow ?

EDIT:

I have this in the beginning of the html :

  <script src="https://www.gstatic.com/firebasejs/5.7.0/firebase-firestore.js"></script>
  <script src="https://www.gstatic.com/firebasejs/5.7.0/firebase-storage.js"></script>
  <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-auth.js"></script>
  <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase-database.js"></script>

I am initializing the app with :

 <script>
          var config = {
            apiKey: "AIzaSxxxxxxxxxxxxxxxZQ14",
            authDomain: "xxxxxx.firebaseapp.com",
            databaseURL: "https://xxxxxxx.firebaseio.com",
            projectId: "xxxxxx",
            storageBucket: "xxxxxxx.appspot.com",
            messagingSenderId: "xxxxxxxxx"
          };
          firebase.initializeApp(config);
          const db = firebase.firestore();
          db.settings({timestampsInSnapshots:true});
     </script>

and those are the only things relate to Firebase I have in this file.


回答1:


Solved by changing version of the imported files with : (thanks a lot Frank)

      <script src="https://www.gstatic.com/firebasejs/5.7.0/firebase-app.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.0/firebase-firestore.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.7.0/firebase-storage.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.0/firebase-auth.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.0/firebase-database.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.0/firebase-messaging.js"></script>
      <script src="https://www.gstatic.com/firebasejs/5.9.0/firebase-functions.js"></script>


来源:https://stackoverflow.com/questions/55272773/firebase-auth-recaptchaverifier-is-not-a-constructor-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!