解析网推送通知shedule错误。

问题描述 投票:0回答:1

我正在尝试设置一个推送通知的后台工作。- 当运行后台作业时,我得到以下错误信息--------------------------------------------。

E2015-02-15T21:45:23.581Z] v20: Ran job push_job with: 输入: {} Failed with: successerror was not called这是我的代码,请帮我解决这个问题。

 Parse.Cloud.job("push_job", function(request, response) {

Parse.Cloud.define('httpRequest', function(request, response) {

 Parse.Cloud.httpRequest({

  method: "POST",
  headers: {
  "X-Parse-Application-Id": "xxxxxxxcxxxxxxxxxxxxx",
  "X-Parse-REST-API-Key": "xxxxxxxxxxxxxxxxxxxxxx",
  "Content-Type": "application/json"
  },
body: {
   "data": {
    "alert": "Local push notification"
  }
 },
 url: "https://api.parse.com/1/push"
 }).then(function() {
response.success();
console.log("Successful push");
 }, function(error) {
response.error(error);
console.log(error);
});
});
}); 
background parse-platform push-notification jobs cloud-code
1个回答
1
投票
   Parse.Cloud.job("PushNtfct_job_TimeEnable", function(request, status) {

   function dateFormat(date, format) {
// Calculate date parts and replace instances in format string    accordingly
   format = format.replace("DD", (date.getDate() < 10 ? '0' : '') +   date.getDate());
 // Pad with 0 if needed
format = format.replace("MM", (date.getMonth() < 9 ? '0' : '') + (date.getMonth() + 1));
// Months are zero-based
  format = format.replace("YYYY", date.getFullYear());
 return format;
}

   var Today = dateFormat(new Date(), "YYYY-MM-DD")+ "T01:25:00";
   // this will sent push notification at 1:25 am daily
 Parse.Push.send({
channels: [ "" ],
 push_time: new Date(Today),
 data: {
 alert: "Today's Push"
  }
 }, { success: function() {
  console.log("Succuss with Time, Local Push notification time was sent    at : " + Today);
 }, error: function(err) {
  console.log(err);
 }
}).then(function() {
  // Set the job's success status
  status.success("Successfully Ran");
}, function(error) {
  // Set the job's error status
   status.error("damn error");
 });
 });
© www.soinside.com 2019 - 2024. All rights reserved.