Я несколько дней ломал голову над уведомлениями.
Я проверил все темы по этой теме, но не смог решить мою проблему.
Когда я планирую более одного уведомления, я получаю каждое из них по одному, НО, когда я нажимаю на одно из уведомлений, «showAlert» срабатывает несколько раз, и мне нужно закрыть его несколько раз.
Вот мой код:
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());
}
Буду очень признателен за любую помощь!