cordova-plugin-local-notifications
cordova-plugin-local-notifications copied to clipboard
local notification not worked when app is open (ios)
local notification not worked when app is open
Plugin version: 0.9.0-beta.3 Platform: ios OS version: 11.1.2 Device manufacturer / model: ipad Cordova version (cordova -v): 7.1.0 Cordova platform version (cordova platform ls): 6.3.0* Plugin config
Expected Behavior LocalNotification not worked in ios when app is open
Tell us what happens instead LocalNotification not worked in ios when app is open but in background and when app is closed it works
please answer me
Hello,
I have the same issue. The notification is received but it doesn't show in the notification center, also no sound.
The problem is that FCM Plugin "onNotification" event is being triggered when a local notification is scheduled. The result is an infinite loop! Here is the sequence: 1- FCM plugin receives a notification in foreground 2- A local notification is scheduled 3- FCM onNotification is triggered again 4- A local notification is scheduled, and it keeps going with that sequence...
What's really weird is that it works fine on Android!
Did you try the foreground and/or silent options?
Did you try the foreground and/or silent options?
Hello Alexander,
As you see in the screenshot, I'm setting foreground to true. The silent option is not what I want because I believe it will not display a banner or pop up a notification in the notification center.
Any suggestions?
Thanks!
Hello Alexander, it is not working in foreground but is working in background and when app is closed
Hmm I've only used it successfully with
trigger: { at: someDate }
Hmm I've only used it successfully with
trigger: { at: someDate }
Can I set the date to current data/time? I want to trigger the notification as soon as I receive a push notification when the app is in foreground.
doesnt work with fcm, foreground notification send by local notification are captured by ionic fcm onNotification event
the same problem as salomari
the same problem
The same problem, how to fix it?
Facing the same problem with the latest release on ios 12.2, but was working earlier don't know why.
@maxgaurav were u able to fix it? in the apple doc it is mentioned that :
This method (UNUserNotificationCenter.current().add
) schedules local notifications only; you cannot use it to schedule the delivery of remote notifications. Upon calling this method, the system begins tracking the trigger conditions associated with your request. When the trigger condition is met, the system delivers your notification. If the request does not contain a UNNotificationTrigger object, the notification is delivered right away.
does this effect?
I fixed with a dirty hack. I am maintaining an array of received notification ids and I only fire local notification if one is not already fired for that id.
if (!this.notificationIds.find(s => s === id)) {
const newId = this.getRandomInt(10000, 99999999);
console.log('LocalNotif', newId, title, body);
this.localNotification.schedule({
id: newId,
title,
text: body,
foreground: true,
icon: '../../../assets/icon/nav-bar-icons/inbox.svg',
});
this.notificationIds.push(newId);
this.localNotification.on('click').subscribe(data => {
this.router.navigateByUrl('mobile/messages');
});
}
After this the infinite loop problem was gone but I started facing another problem that when my app is in foreground the onNotification
callback is not getting more than once. Any help on this?
@kush-prof Thanks for sharing your hack, I managed to use it with a few minor changes. I haven't had any problems with onNotification being triggered only once, hope you solved it at the end.