如何使用Parse.com的云代码发送可折叠推送通知

时间:2014-09-07 20:31:52

标签: parse-platform google-cloud-messaging cloud-code

我正在使用Parse.com通过Cloud Code发送推送通知。这些通知是“发送到同步”,所以我希望它们可以折叠。可折叠意味着如果关闭设备或者不接收推送通知,则不应建立这些通知。当我的手机打开时,我不需要一堆未送达的推送显示告诉我同步。我只需要一个。我认为在Cloud Code中无法做到这一点。有没有办法让你的推送通知可折叠?这是我的CloudCode。

Parse.Cloud.afterSave("Tagnames", function (request) {
   //Get the Customer that is pointed to in the AlarmDefinitions object.
  query = new Parse.Query("Customers");
  query.get(request.object.get("customer").id, {
    success : function (cust) {
      //We have the customer pointed to by the AlarmDefinition.
      //Create the json payload data we will send to our clients.
      console.log("Customer=" + cust.get("customer"));
      console.log("action:" + "com.jrb.scadaalarm.rcvr.UPDATE_TAGNAMES");
      //send the push so that all customers can get notified.
      Parse.Push.send({
        channels : [cust.get("customer")],
        data: {
          action: "com.jrb.scadaalarm.rcvr.UPDATE_TAGNAMES"
        }
      }, {
        success : function () {
          // Push was successful
          console.log("Push successful.");
        },
        error : function (error) {
          // Handle error
          console.error("Push failed: " + error.code + " : " + error.message);
        }
      });

      //
    },
    error : function (error) {
      console.error("Got an error " + error.code + " : " + error.message);
    }
  });
});

1 个答案:

答案 0 :(得分:1)

不幸的是,它看起来并不像Parse支持可堆叠通知。从Parse档案中查看此答案。

https://parse.com/questions/android-stack-push-notifications