I want my Meteor app to send local notifications to the user. This would require the app to run in the background.
How can this be done?
I’ve got this plugin:
In my startup I have:
if (Meteor.isCordova) {
cordova.plugins.notification.local.hasPermission(function (granted) {
if (!granted) {
cordova.plugins.notification.local.registerPermission(function (granted) {
});
}
});
}
This results in the app asking, upon startup, if it can send push notifications.
Then, I have this:
Meteor.setInterval(function() {
if (Session.get("cordovaIsRunning")) {
getLocation();
}
if (Meteor.isCordova) {
cordova.plugins.notification.local.hasPermission(function (granted) {
if (granted) {
var date = new Date();
cordova.plugins.notification.local.schedule({
id: 1,
title: "Message Title",
message: "Message Text",
at: date,
icon: "/icon.png"
});
}
});
}
}, 5000);
This doesn’t do anything.
How to make this work?