@benzata wrote:
I have been busting my head for a few days with the notifications.
I’ve checked all the topics on the subject, but could not resolve my problem.
When I schedule more than one notification, I receive each of them once, BUT when I click one of them, the “showAlert” triggers multiple times and I need to close multiple alerts.
Here’s my code:
constructor(private activatedRoute: ActivatedRoute, private channel: DataService, public alertController: AlertController, private plt: Platform, private LocalNotif: LocalNotifications, public actionSheetController: ActionSheetController) { this.plt.ready().then(() => { this.LocalNotif.on('click').subscribe(res => { const msg = res.data ? res.data.mydata : ''; this.showAlert(res.title, res.text, msg); }); this.LocalNotif.on('trigger').subscribe(res => { const msg = res.data ? res.data.mydata : ''; this.showAlert(res.title, res.text, res.id); }); }); } scheduleNotification(Value, Value2, Value3) { this.LocalNotif.schedule({ id: Value3, title: Value2, text: Value2, foreground: true, led: { color: '#90EE90', on: 500, off: 500 }, smallIcon: 'res://icontransparent.png', icon: 'file://assets/icon/icon-big.png', sound: 'file://assets/Sounds/me-too.mp3', data: { mydata: 'Hidden message 1'}, trigger: { at: new Date(Value), count: 1} }); console.log(new Date(Value)); } scheduleNotification2(Value, Value2, Value3) { this.LocalNotif.schedule({ id: Value3, title: Value2, text: Value2, foreground: true, led: { color: '#90EE90', on: 500, off: 500 }, smallIcon: 'res://icontransparent.png', icon: 'file://assets/icon/icon-big.png', sound: 'file://assets/Sounds/me-too.mp3', data: { mydata: 'Hidden message 2'}, trigger: { at: new Date (new Date(Value).getTime() - 900000), count: 1} }); console.log(new Date(Value).getTime()); } showAlert(head, sub, msg) { this.alertController.create({ header: head, subHeader: sub, message: msg, buttons: ['OK'], }).then(alert => alert.present()); }
I would be extremely grateful for any ideas!
Posts: 1
Participants: 1