React-native-push-notification: failed to post notification on channel "fcm_fallback_notification_channel"

Created on 4 Feb 2021  路  6Comments  路  Source: zo0r/react-native-push-notification

Hi Guys,

I'm trying to create a Local Push Notification, but it returns this error:

errorRN

Trying to understand the error, I think it is necessary to create a channel, following the documentation: https://github.com/zo0r/react-native-push-notification#channel-management-android, I just created with the code PushNotification.createChannel and I don't where to refer the channelId, I don't know if this is it, just a hint

Most helpful comment

Hi @diegobonagurio
You just use the code inside the link you provided.

 PushNotification.createChannel(
    {
      channelId: "channel-id", // (required)
      channelName: "My channel", // (required)
      channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
      playSound: false, // (optional) default: true
      soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
      importance: 4, // (optional) default: 4. Int value of the Android notification importance
      vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );

All 6 comments

Hi @diegobonagurio
The notification channel must be created to use local notification on Android. There is a fallback to the default Firebase channel in case it's not defined (in localNotification method) but Firebase SDK create the channel only in some case (killed app).
The channelId is use in localNotification method.
Regards,

Hi @Dallas62 !

So, I'm not using Firebase, just local notification.

Following what you said, where do I create this notification channel?

Hi @diegobonagurio
You just use the code inside the link you provided.

 PushNotification.createChannel(
    {
      channelId: "channel-id", // (required)
      channelName: "My channel", // (required)
      channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
      playSound: false, // (optional) default: true
      soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
      importance: 4, // (optional) default: 4. Int value of the Android notification importance
      vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );

@Dallas62

Will it be something like that?

import PushNotification from 'react-native-push-notification';
import {Platform} from 'react-native';

PushNotification.configure({
  // (required) Called when a remote or local notification is opened or received
  onNotification: function(notification) {
    console.log('LOCAL NOTIFICATION ==>', notification)
  },
  popInitialNotification: true,
  requestPermissions: Platform.OS === 'ios',
})

export const LocalNotification = () => {
  PushNotification.localNotification({
    channelId: "com.pushnotification",
    autoCancel: true,
    bigText:
      'This is local notification demo in React Native app. Only shown, when expanded.',
    subText: 'Local Notification Demo',
    title: 'Local Notification Title',
    message: 'Expand me to see more',
    vibrate: true,
    vibration: 300,
    playSound: true,
    soundName: 'default',
    actions: '["Yes", "No"]'
  });

  PushNotification.createChannel(
    {
      channelId: "com.pushnotification", // (required)
      channelName: "com.pushnotification", // (required)
      channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
      playSound: false, // (optional) default: true
      soundName: "default", // (optional) See `soundName` parameter of `localNotification` function
      importance: 4, // (optional) default: 4. Int value of the Android notification importance
      vibrate: true, // (optional) default: true. Creates the default vibration patten if true.
    },
    (created) => console.log(`createChannel returned '${created}'`) // (optional) callback returns whether the channel was created, false means it already existed.
  );
}

Yes but the channel must exist before the notification is triggered

Nice @Dallas62

It's worked! 馃槃

Thank you!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DaniShalash picture DaniShalash  路  3Comments

sungjinoh picture sungjinoh  路  3Comments

Kiran0791 picture Kiran0791  路  3Comments

cidevant picture cidevant  路  3Comments

GastonEDiaz picture GastonEDiaz  路  3Comments