I'm using Ionic for mobile dev, i'm actually using LocalNotifications
Every 5 minutes i check in my server if have new question:
this.checkQuestions();
this.IntervalId = setInterval(() => {
this.checkQuestions();
}, 300000);
My function checkQuestions()
make a for()
with the data of my server:
for (var i = 0; i < res.data.notificar.questions.length; i++) {
this.localNotifications.schedule({
id: i,
priority: 2,
text: 'Produto: ' + res.data.notificar.questions[i].produto.substring(0, 20) + '...',
title: 'Nova pergunta, conta: ' + res.data.notificar.questions[i].conta,
smallIcon: 'res://notification',
foreground: true,
});
}
The problem is when my app is closed, this logic don't run and my customers don't receive the notifications. There's some alternative in Ionic to send notification when my app is closed?
I need to check every 5 minutes in my server even the app is closed.