【问题标题】:How to pass the user object that triggered the push notification如何传递触发推送通知的用户对象
【发布时间】:2015-09-07 09:08:18
【问题描述】:

我已将所有用户的位置保存在安装对象中。我还有另一个名为 locationObject 的对象,当当前用户发送他的当前位置时它会更新。当它这样做时,云代码会将他的当前位置与所有其他保存的位置进行比较,并向附近的用户发送推送通知。这是我的生成推送通知的代码。

Parse.Cloud.afterSave("locationObject", function (request) {
    var geoPoint = request.object.get("myCurrentLocation");
    var pushQuery = new Parse.Query(Parse.Installation);
    pushQuery.near("significantLocationUpdate", geoPoint);
    pushQuery.limit(100);

    Parse.Push.send({
        where: pushQuery,
        data: {
            alert: "some user is nearby"
        }
    }, {
        success: function() {
            console.log("push was successful");
        },
        error: function(error) {
            console.log("sending push failed")// Handle error
        }
    });
});

现在,我的问题是,如何将触发推送通知的用户对象及其当前位置传递给我要发送推送通知的用户?

【问题讨论】:

  • 您是否查看过推送中的其他信息?

标签: ios parse-platform parse-cloud-code


【解决方案1】:

您可以在推送中添加additional data。例如:

data: {
  alert: "some user is nearby",
  user: [user objectId],
  latitude: [user latitude],
  longitude: [user longitude]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-27
    相关资源
    最近更新 更多