[英]No firebase.app.App instance is currently initialized in Angular Application
I was using firebase mobile authenication in web application, when I use recaptchaVerifier, when the recaptchaVerifier is not shown and given this error, I am aready using realtime database in the project that working fine but dont know why at mobile authenitcation module is not working app.module.ts我在 web 应用程序中使用 firebase 移动身份验证,当我使用 recaptchaVerifier 时,当 recaptchaVerifier 未显示并出现此错误时,我已经在项目中使用实时数据库工作正常但不知道为什么在移动身份验证模块不工作应用程序.module.ts
import { environment } from './../environments/environment';
imports: [ AngularFireModule.initializeApp(environment.firebaseConfig)]导入:[ AngularFireModule.initializeApp(environment.firebaseConfig)]
component.module.ts组件.module.ts
ngOnInit() {
this.windowRef = this.win.windowRef
this.windowRef.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container')
this.windowRef.recaptchaVerifier.render()
Please help me to sortout this!请帮我解决这个问题!
You need to Initialize the firebase instance with the initializeApp method您需要使用 initializeApp 方法初始化 firebase 实例
In the Component's ngOnInit() function add the following line before you create the RecaptchaVerifier.在组件的 ngOnInit() function 中,在创建 RecaptchaVerifier 之前添加以下行。
firebase.initializeApp(config);
this.windowRef.recaptchaVerifier.render()
The correct place for initializing the firebase config is under app module.初始化 firebase 配置的正确位置是在应用程序模块下。 That you have done correctly.
你做对了。 Just add a delay of 2 to 3 seconds like below.
只需像下面这样添加 2 到 3 秒的延迟。 It will not give any error.
它不会给出任何错误。 It looks like initializing firebase config takes few seconds time.
看起来初始化 firebase 配置需要几秒钟的时间。
ngOnInit() {
setTimeout(() => {
this.windowRef = this.win.windowRef
this.windowRef.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container')
this.windowRef.recaptchaVerifier.render()
}, 2000);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.