我想知道在Parse Server上是否有时间表推送?(我使用的是Back4App)
下面是我的云代码:
Parse.Cloud.define("pushMultiple",async (request) => {
//Getting Current Date instance
var d = new Date();
//Where I live Current Hour is 14, so setting it to 15
d.setHours(15);
//Sending push to a specific device
return Parse.Push.send({
push_time: d,
channels: [ "t1g.com"],
data: {alert: "The Giants won against the Mets 2-3."}
},{ useMasterKey: true });
});但代码似乎不起作用。推送会立即发出。
如果不可能,请告诉我如何使用云作业安排推流。一个代码片段会非常有帮助。另外,云作业在发送完推流后是否会停止运行?
发布于 2020-04-05 03:35:50
根据this文档,setHours方法不会将您的值添加到日期中,而只是替换它。
试试这个:
var extraTime = 1000*60*60*15; //15 hours
var currentDate = new Date();
//since date object is just number we can add our extra time to our date.
var pushDate = currentDate + extraTime; //push date is 15 hours later than now
return Parse.Push.send({
push_time: pushDate,
channels: [ "t1g.com"],
data: {alert: "The Giants won against the Mets 2-3."}
},{ useMasterKey: true });编辑:解析文档表明还不支持push_time。https://docs.parseplatform.org/parse-server/guide/#push-notifications
文档可能已经过时,或者如果您使用的是back4app,它们可能会在其服务器上实现此功能。
https://stackoverflow.com/questions/61026124
复制相似问题