Syed Hassan
Syed Hassan

Reputation: 438

firebase.notifications() is throwing error in react-native-firebase

I have successfully integrated firebase on my mobile application. for now I am testing it on android. I am successfully receiving notification. My next step is to trigger the event when app is in foreground and in background and read the data. for this matter I saw the documentation and used firebase.notifications().displayNotification(). But it is throwing error.

Ensure you have:

1) Installed the required Firebase Android SDK dependency 'com.google.firebase:firebase-notifications' in your 'android/app/build.gradle' file.

2) Imported the 'io.invertase.firebase.notifications.RNFirebaseNotificationsPackage' module in your 'MainApplication.java' file. 3) Added the 'new RNFirebaseNotificationsPackage()' line inside of the RN'getPackages()' method list.

Upvotes: 3

Views: 7509

Answers (2)

Rahul Shakya
Rahul Shakya

Reputation: 1425

I got the same error Error: You attempted to use a firebase module that's not installed on your Android project by calling firebase.notifications() using invertase firebasev6...

After a couple research I found that notification should be implementation in rnfirebase.io thats firebase v5 and lesser

So, invertase decided not to use notification in their firebase package v6.

To use notifcation u can refer to their notifee package when doc is in alpha version or you can use wix/react-native-notifications etc... which is extra package

Upvotes: 1

Noah Allen
Noah Allen

Reputation: 796

It sounds like you need follow the instructions on this page to install the Notifications dependency. They recently rewrote the notifications part of react-native-firebase, so this might also be needed for your use case.

Upvotes: 6

Related Questions