Ionic latest 3 Firebase and Firebase Cloud problem

#1

Hey guys, i want to use firebase as database for my mobile app, but i want to use firebase push notifications aswell.

So if i want to use the firebase push notifications i need to get angular fire and init the database settings in my app.module.ts and if i want to use the firebase ( for realtime database ) i need to init the firebase config in my app.component.ts .

So if i init the firebase settings in app.module.ts with angular fire it’s shows that i want to access firebase before the init ( that’s because i have services to firebase realtime database)

But if init my firebase in app.component.ts angular fire is not working.

If i init the firebase in app.component.ts and in app.module.ts it shows that i can’t have 2 configs to the same firebase database.

My question is how do i use firebase for push notifications and as realtime database .

Thanks.

#2

bumb, no one knows anything?

#3

It might help others to show some code

#4

Okay, so if we are using angular fire we need to init Firebase in our app.module.ts like this :slight_smile:

imports: [
BrowserModule,
AngularFire(firebase.initializeAp(config))
IonicStorageModule.forRoot(),
IonicModule.forRoot(MyApp)
],

If i init firebase like this there is an error which says that i’m trying to use firebase before it is init.
If i init firebase in app.component.ts on platform.ready() it says taht angular fire is not initiliazed and i can’t use firebase push notification.

My question is where i need to init Firebase if i want to use firebase cloud and firebase realtime database for the same application.

So i want to have firebase.database().ref(‘sometable’) , but i want to use the database for push notifications aswell.

#5

Looks like you need to import the module for init and then import all the other modules, for example, this is what I have in my imports:

    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAuthModule,
    AngularFirestoreModule,
    AngularFireStorageModule,
    AngularFireFunctionsModule,
1 Like
#6

I will try that in a minute and will let you know.

#7

So what i did is i uninstalled firebase, then i installed angular fire 2 with angularFireModule, imported the modules as you said and it worked like charm :slight_smile: thanks

#8

sweet! happy to help :slight_smile: