我想知道 Parse Server 上是否可以使用 Schedule Push?(我正在使用 Back4App)
I was wondering if Schedule Push is available on Parse Server? (I'm using 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"], data: {alert: "The Giants won against the Mets 2-3."} },{ useMasterKey: true }); });但是代码似乎不起作用.推送会立即发出.
But the code does not seem to be working. The push is sent out immediately.
如果不可能,请告诉我如何使用云作业安排推送.代码片段将非常有帮助.云作业在发送完推送后还会停止运行吗?
And if it's not possible, please let me know how I can schedule push using a Cloud Job. A code snippet would be very helpful. Also will the Cloud Job stop running after it has completed sending the push?
推荐答案根据 this 文档 setHours 方法不会将您的值添加到您的日期,而只是替换它.
According to this document setHours method doesnt add your value to your date but just replace it.
试试这个:
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"], data: {alert: "The Giants won against the Mets 2-3."} },{ useMasterKey: true });解析文档说 push_time 尚不支持.docs.parseplatform/parse-server/guide/#推送通知
Parse docs says push_time is not supported yet. docs.parseplatform/parse-server/guide/#push-notifications
文档可能已过时,或者如果您使用的是 back4app,他们可能会在其服务器上实现此功能.
Docs can be outdated or if you are using back4app, they may be implemented this feature to their servers.
更多推荐
在 Parse 上安排推送通知
发布评论