在 Parse 上安排推送通知

编程入门 行业动态 更新时间:2024-10-10 23:18:35
本文介绍了在 Parse 上安排推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道 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 上安排推送通知

本文发布于:2023-11-27 11:37:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637900.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   Parse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!