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

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
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!!
Most helpful comment
Hi @diegobonagurio
You just use the code inside the link you provided.