What are steps to receive push notification on mobile device? (FCM)

Hello,

I am trying to set up a react-native project using @trycourier/react-native-inbox. I have successfully received in-app notifications. Now, I am trying to enable push notifications and trying to configure the FCM channel for push notifications. I have a few questions about its process.

In the documentation, it says to paste the complete contents of the JSON file you download from Firebase into the configuration field. What is a configuration field?

Secondly, In the Profile Requirements section of the documentation, it’s written that

To deliver a message to a recipient over Firebase FCM, Courier must be provided with the recipient’s Firebase registration token.

I got the device token but I do not know where to send it. What should I do? Where should I send the device token?

Hey @malikabdulazizakbar,

Your Firebase configuration field is inside the FCM integration settings where you can initially set up Firebase.

Once you have the Firebase registration token, you need to include this token inside the “message” object of your Send request. There are no additional params that need to be included in the profile.

3 Likes

Thanks for the response.
Can you please mention here what is the API endpoint for Send Request?

Certainly! Courier’s Send endpoint is: https://api.courier.com/send

You can find more info on our Send API here.

1 Like

I did all of this but still, I am not getting any push notifications (in form of banners). I got my device code using the following.

import messaging from '@react-native-firebase/messaging'
useEffect(() => {
    messaging()
      .getToken()
      .then(token => {
        console.log("Device Token: ", token);
        registerDevice(token);
      });
  }, []);

And then I send my post request as follows:

function registerDevice(token: string) {
  const headers = {
    Authorization: 'Bearer pk_prod_M27KK4DRC54G1GJB6HZA9NG89MF8'
  }
  const body = {
    message: {
      template: "2NAGY3ZZQYMDYVN1E1PHEJAW0T9A",
      to: {
        firebaseToken: token
      },
    },
  }
  axios.post('https://api.courier.com/send', body, {
    headers: headers
  }).then(res => { console.log(res.status) }).catch(err => { console.log(err) })
}```

Also, I configured my FCM as displayed in the image:
![Screenshot 2022-07-19 at 12.43.49 PM|656x500](upload://uQ6HdVCTbBuEdHYRRAxBO45IuXv.png)


When I send the push notification using the FCM channel, I get the notification in the inbox but the notification banner does not appear on my device. What should be done to make that appear?