javascript - 将服务器推送通知解析到用户数组
<p><p>我正在传递字符串类型的“消息”和 <code>()</code></p> 类型的“用户”
<pre><code>Parse.Cloud.define("invite", function(request,response) {
var message = request.params.message;
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.containedIn("user",request.params.User);
Parse.Push.send({
where: pushQuery,
data : {
alert: message,
"badge": 1,
}
}, {
success: function(result) {
console.log(JSON.stringify(result));
response.success(result);
},
error: function(error) {
console.error(JSON.stringify(error));
response.error(error.message)
},
useMasterKey: true
});
});
</code></pre>
<p>尝试运行此代码时,我在日志中收到以下错误</p>
<pre><code>_PushStatus Qwd8rDJKLu: error while sending push code=107, message=bad $in value
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>提供给 <a href="https://github.com/parse-community/Parse-SDK-JS/blob/de4bc1c3597ed21a86b542500a84070ce1c9d742/src/ParseQuery.js#L841" rel="noreferrer noopener nofollow"><code>Parse.Query.containedIn</code></a> 的第二个参数必须是 <code>数组</code>。 <code>bad $in value</code> 错误消息的唯一方法 <a href="https://github.com/parse-community/parse-server/blob/960431b92d9d2bb77f2ee082648bd4b140581a67/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js#L418" rel="noreferrer noopener nofollow">can appear</a>当第二个参数不是 <code>undefined</code> 而不是 <code>array</code> 时。</p>
<p>您应该确保 <code>request.params.User</code> 的值是一个实际的 <code>array</code>。您可以使用 <code>console.log(typeof request.params.User)</code> 进行检查。</p>
<p>正如您所说,您正在传递类型 <code>()</code>,它可能会被转换为带有括号和所有字符串的实际字符串。</p></p>
<p style="font-size: 20px;">关于javascript - 将服务器推送通知解析到用户数组,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/51164282/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/51164282/
</a>
</p>
页:
[1]