如何在 iOS(Obj-C) 的解析中插入一行后发送推送通知

How to send push notification after a row is inserted in parse for iOS(Obj-C)

我有一个订单 table 正在解析中。在 table 中插入一行后,我想向 iOS 设备发送推送通知。如何为这个特定任务编写云代码?我阅读了解析文档,但我无法理解频道、安装和其他与推送通知相关的内容。我看过各种关于此的博客,但我无法获得云代码的正确答案以及如何在 iOS 中调用该代码。任何帮助表示赞赏。谢谢。

您没有说明要将推送通知发送到哪些设备,因此我无法提供更具体的示例,但这里有一个 afterSave 方法用于 class "Location"。在此代码中,定义了一个查询,用于标识与更新位置关联的所有安装,并向这些设备发送 'silent push' -

Parse.Cloud.afterSave("Location", function(request) {

  query = new Parse.Query("Installation")
  query.equalTo("location",request.object)

  Parse.Push.send({ 
      where: query,
      data: {
          "content-available" : "1",
          event: "locationUpdate"
      } 
  },{
    success:function() {
   },
   error:function() {
       console.error("Error in push "+error.code+" : "+error.message);
       }
   });

});