gpt4 book ai didi

javascript - 无法将 Parse 安装设置为两个 channel 以进行推送通知

转载 作者:行者123 更新时间:2023-12-03 10:16:17 27 4
gpt4 key购买 nike

我正在尝试让我的 Parse 云代码的一部分设置安装 channel 以用于推送通知。我希望它将安装设置为两个 channel ,如下所示:

var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.equalTo('userId', user);

installationQuery.first().then(function(result) {
result.set('channels', [user, "highPush"]);
result.save();
});

我在这里所做的是查找与特定 userId 关联的安装,然后设置 installation对象的“channels”属性同时设置为用户名(user变量)字符串和字符串“highPush”。

问题是运行此代码似乎仅将其设置为“highPush”,而不是两者。当我尝试使用显式 user 时像下面这样的字符串,它成功地将其设置为两者,但当我使用 user 时则不然包含相同 userId 字符串的变量。可能是什么原因造成的?

result.set('channels', ["EG7Mf6mDkT", "highPush"]);

记录 user像下面这样的变量成功打印,所以我知道它存在。

console.log('set it to high push, and the userId is' + user);

最佳答案

我怀疑 user 这里真的是一个字符串。您确定 user 不是 Parse.User 吗?

如果它确实是一个 Parse.User 对象,请使用以下方法获取 objectId:

result.set('channels', [user.id, "highPush"]);

关于javascript - 无法将 Parse 安装设置为两个 channel 以进行推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29855241/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com