I see in the control panel possibility to send push notification to all users. Is it possible to do the same using API? I tried already to send a request with empty tokens array "tokens": []
however, no notifications were delivered.
If it’s not yet possible to do through the API, can you suggest me the best practice how to store these tokens on backend side in DB? I see that app generates token each time on startup, and I don’t have and don’t want to have registration. So, basically, if user will kill and re-open app 100 times I will save 100 different tokens for his device.
How can I understand that some tokens are already outdated and should be removed from DB?
So far I used the standard code to register device in ionic platform:
var push = new Ionic.Push({
"debug": true,
"pluginConfig": {
"ios": {
badge: "false",
sound: "true"
}
},
"onNotification": function(notification) {
var payload = notification.payload;
console.log(notification, payload);
},
"onError": function(err) {
console.log(JSON.stringify(err));
}
});
push.register(function(token) {
console.log("Device token:",token.token);
push.saveToken(token); // persist the token in the Ionic Platform
});