I am trying to implement Firebase Phone Number Authentication as described Uncaught TypeError: Cannot read property 'RecaptchaVerifier' of undefined at app.js:22 please go through the code,i am not able to figure out.and reply has soon as possible.
app.js
// window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
// 'size': 'invisible',
// 'callback': function(response) {
// // reCAPTCHA solved, allow signInWithPhoneNumber.
// onSignInSubmit();
// }
// });
//firebase.auth().languageCode = 'it';
// var recaptchaResponse = grecaptcha.getResponse(window.recaptchaWidgetId);
$('#verify_otp_model').hide()
$('#errorbox').hide()
// phone auth
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('getotp', {
'size': 'invisible',
'callback': function(response) {
// reCAPTCHA solved, allow signInWithPhoneNumber.
//onSignInSubmit();
}
});
// [END appVerifier]
recaptchaVerifier.render().then(function(widgetId) {
window.recaptchaWidgetId = widgetId;
// updateSignInButtonUI();
});
);
app.html
<!DOCTYPE html>
<html>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.14.3/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyDLFhLuJ_SOJDqLcJOi2-7tUhLrJ8wstZU",
authDomain: "voting-6d410.firebaseapp.com",
databaseURL: "https://voting-6d410.firebaseio.com",
projectId: "voting-6d410",
storageBucket: "voting-6d410.appspot.com",
messagingSenderId: "769418906177",
appId: "1:769418906177:web:852a15ba5e50033fd514c0",
measurementId: "G-37YQP4X9WG"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
</head>
<body class="gray-bg">
</body>
</html>
This issue arises due to the Firebase JS SDK version. I solved by changing to this version -
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
This issue is due to the new version, change your script with
<script src="https://www.gstatic.com/firebasejs/6.0.2/firebase-app.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.