Open michaelVictoriaDev opened 4 years ago
Hi,
The way you use channel id is incorrect.
Please define a unique id of channel. _.toString
of an array doesn't make sense.
Regards
Hi @Dallas62 Actually the localnotification when the app is active is trigger, but when in background is not trigger, .
Follow the Channel documentation, this will probably solve your issue.
My firebase structure is looks like this, so basically when there's notification or order all that value of objects will be changed,
My localnotification snippet looks like this, I listened the timestamp when there's changed in the firebase, so basically the createChannel is not needed anymore cause I have an order_id equivalent to channel, I used the number-to-words library so it will be string words not numbers. but still the foreground is not happening.
sendMessage = (notifMessage, order_id) => {
console.log('notifMessage', notifMessage)
console.log('order_id', order_id)
var channel
PushNotification.createChannel(
{
channelId: converter.toWords(order_id), // (required)
channelName: converter.toWords(order_id), // (required)
// channelDescription: "A channel to categorise your notifications", // (optional) default: undefined.
soundName: "notif", // (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.
);
PushNotification.localNotification({
channelId: converter.toWords(order_id),// (required)
message: `${notifMessage}`, // (required)
soundName: "notif",
smallIcon: "icon",
vibrate: true,
vibration: 300,
number: 10,
playSound: true,
tag: order_id,
// ignoreInForeground: false,
});
}
Make sure you follow this documentation https://github.com/react-native-push-notification-ios/push-notification-ios
react-native-push-notification is dependent on this library for IOS (@react-native-community/push-notification-ios)
my index.js
my notification.js trigger this
AndroidManifest.xml looks like this.
but the foreground is not working.