Hello guys,
Since push notifications dont work when app is in foreground(for my device atleast) i dispatch Local Notification instead when app is in foreground. Everything works fine until there are 2+ Local Notifications dispatched one after another,and if 1st local notification is not cleared the second one “overrides” it and only second (last) notifications is shown, they do not stack up like in push notification case where if i get 2+ push notificaton all of them are shown in notification area on top. Any idea what could cause this? Thanks.
can you share the code you’ve tried?
PushNotifications.addListener('pushNotificationReceived', (notification) => {
LocalNotifications.schedule({
notifications: [
{
title: notification.title,
body: notification.body,
id: Math.random(),
},
],
});
});
I just did everything from documentation basically, whole setup for push notifications and all events, also i have some events for localnotification(these are basically all copied from documentantion)
. Idk maybe im doing it wrong, its my 1st time using something like this.
Push notifications event fires when they are received but push notification isnt shown(if i alert alert shows but not notification) therefore i am making Local Notification that will be displayed instead
I dont know if thisis what you wanted to see, but tell me if you need anything else. Thanks
check the group
property of the LocalNotificationSchedule
, if you don’t provide a group the won’t be grouped
I tried it, its not working.
Just to make it clear, im not sending multiple notifications at the same time. At certain event notification happens, lets say i get one notification now and 5 seconds later i get another one, the 1st one is not visible in notification tray(system tray or whatever its called, sorry) only the one i got last. I dont understand this behavior, since all notifications should be visible as they come.
Again, this does not happen when i get push notifications, they are all shown as many as i get.
I did little experimenting and the problem seems to be due to id property. I forgot that it gives number in range of 0-1, and it made all notifications have 0 id(im assuming this) so they did not stack up and only waas showing last one since they were all same id. After changing code to make all notifications have different id it is now working as expected.
Also one more question is it good to use local notification inside push notification like i did here, because i dont get push notification when app is in foreground? Thanks
1 Like