react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

How to get the title of the firebase remote notification

Open aditya3vedi opened this issue 4 years ago • 3 comments

Question

Hi, I have a question regarding remote notifications ( firebase ), is there a way to get the notification title and image, etc. I know I can access the notification payload but I can't find anything regarding getting the title and text of the remote notification.

I guess I might not be looking in the correct place, can someone please point me in the right direction?

aditya3vedi avatar May 28 '21 09:05 aditya3vedi

Hi @aditya3vedi You can use a data-only notification and pass all data to the localNotification method. This will allow you to use all features of the local notification.

PushNotification.configure({
  // ...

  // (required) Called when a remote is received or opened, or local notification is opened
  onNotification: function (notification) {
    console.log("NOTIFICATION:", notification);

    // process the notification
    if(!notification.userInteraction) {
        PushNotification.localNotification(notification.data);
    }

    // (required) Called when a remote is received or opened, or local notification is opened
    notification.finish(PushNotificationIOS.FetchResult.NoData);
  },

  // ...
});

Regards

Dallas62 avatar May 28 '21 09:05 Dallas62

Hey @Dallas62 Thanks for the quick response. For our project, we are using the Firebase console to send remote notifications. And with how much I can find out, I guess it is not possible to send data-only notifications from the console.

aditya3vedi avatar May 28 '21 12:05 aditya3vedi

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 29 '22 00:05 github-actions[bot]