firebase cloud messaging with react native?

Viewed 1902

I have a react native project that is already connected to my firebase project. I use firebase as my database. Everything works great. But...

I am trying to get a simple firebase cloud messaging test to work with my react native android app. As I said, I already have firebase in use with my app for db purposes and for authentication.

I am using the react-native-firebase package (http://invertase.io/react-native-firebase) to do all my firebase work. I followed the directions on their site to get the messaging to work, but I haven't had any success.

I have followed the installation directions here: http://invertase.io/react-native-firebase/#/installation-android

All the database stuff works fine, but no luck with messaging. I am sending out test notifications using the firebase notifications console. I get the firebase token using this code in my app.

firebase.messaging().getToken()
        .then((token) => {
          firebase.database().ref(user.providerData[0].uid+'/agents/'+user.providerData[0].uid+'/fcmToken').set(token);
        });

That code successfully gets the token and saves it to my firebase database. I then copy the token manually from my db and use it in my firebase notification console to send out a test notification. I know that the app is supposed to be running in the background. To get my app in the background I simply hit the home button. Then I send my test message. I don't get any errors in the firebase notification console and it says my token I supplied is all good. After a few seconds it says the notification status is completed. However in my app, nothing appears in my system tray, no notifications.

Does my app have to be in production mode or something? Anyone else get react-native-firebase to work with firebase cloud messaging on android?

I use the firebase console to send test messages enter image description here

0 Answers
Related