Firebase cloud messaging with react native?

I have a responsive native project that is already connected to my firebase project. I am using firebase as my database. Everything works fine. 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 a firebase to use with my application for db targets and for authentication.

I am using the action-native-firebase package ( http://invertase.io/react-native-firebase ) to do all my firebase work. I followed the directions on my site to get the messaging to work, but I was not successful.

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

The whole database works fine, but no luck with messaging. I am sending test notifications using firebase notification console. I am getting firebase token using this code in my application.

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

      

This code successfully gets the token and stores it in my firebase database. Then I copy the token manually from my db and use it in firebase notification console to send a test notification. I know the app needs to run in the background. To get my application running in the background, I just hit the home button. Then I post my test message. I am not getting any errors in the firebase notification console and it says my token I have supplied is good. After a few seconds, it reports that the notification status is complete. However, my application doesn't show anything in my system tray, no notifications.

Should my application be in production mode or something else? Anyone else get react-native-firebase to work with firebase cloud messaging on Android?

I am using firebase console to send test messages enter image description here

+3


source to share





All Articles