I have this one analysis that is an async function that has for loop in it such that for every array of device tokens, we would take each device token and send some data to each device. I am able to get context.logs in this but this method does not work when I used sendData function, for example:
for (var i=0; i < array_dev.length; i++){
const device = new Device({ token: array_dev[i] });
//context.log("device " + JSON.stringify(device))
if (!alert_devices.length) {
const check_to_save = {
variable: 'check',
value: "Online"
};
device
.sendData(check_to_save)
.then(context.log("Successfully Inserted"));
context.log("It's Online!")
}
else{
const check_to_save = {
variable: 'check',
value: "Offline"
};
context.log("It's Offline!")
}
context.log("Sending notifications");
}
I would like to know how I can send the data in this case: The logs look like this:
[2021-05-05 13:42:48] Sending notifications
[2021-05-05 13:42:48] It’s Online!
[2021-05-05 13:42:48] It’s Online!
[2021-05-05 13:42:48] It’s Online!
[2021-05-05 13:42:48] It’s Online!
[2021-05-05 13:42:48] Successfully Inserted
[2021-05-05 13:42:48] Successfully Inserted
[2021-05-05 13:42:48] Sending notifications
[2021-05-05 13:42:47] Starting analysis 609042131b9b440012769ff4
The context.logs do work but not it does not send the data to these devices. If you can help, I will greatly appreciate it. Thanks!