简体   繁体   English

没有 firebase.app.App 实例当前在 Angular Application 中初始化

[英]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.

相关问题 没有 Firebase 应用程序“[默认]”错误,但 firebase 已经初始化 - No Firebase App '[Default]' error but firebase is already initialized 检查 Firebase 应用程序是否已在 python 中初始化 - check if a Firebase App is already initialized in python 如何检查 Firebase 应用程序是否已在 Android 上初始化 - How to check if a Firebase App is already initialized on Android AngularFirestore 已经在 [DEFAULT] Firebase 应用程序上用不同的设置初始化 - AngularFirestore was already initialized on the [DEFAULT] Firebase App with different settings Firebase 标准事件 | 应用实例限制 - Firebase Standard Events | App Instance Limit 没有创建 Firebase App '[DEFAULT]' - 尽管正在初始化 Firebase,但调用 Firebase.initializeApp()) - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()) although Firebase is being initialized 如何获取 Web App 的 Firebase Analytics App Instance Id? - how to get Firebase Analytics App Instance Id for Web App? 部署失败 Firebase 使用简单的 Angular 应用程序托管 - Deployment fails to Firebase Hosting with simple Angular App 同一个 Angular 应用程序中的多个 Firebase 项目 - Multiple Firebase Project in same Angular app 初始化 Firebase 后出现“无默认应用”异常 - 'no default app' exception after Firebase has been initialized
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM