Sen*_*nto 6 cloud push where parse-platform
我正在使用Parse,我无法使这种方法起作用.
我们的想法是从"云代码"中的任何平台向具有已知用户标识符的单个用户发送推送.
查询我试过没有推送到该用户(实际上没有推送到任何用户)
PF通过用户指针安装:
var targetUser = new Parse.User();
targetUser.id = userID;
var query = new Parse.Query(Parse.Installation);
query.equalTo('user', targetUser);
在PFUser本身中查询
var query = new Parse.Query(Parse.User);
query.equalTo('objectId', userID);
该方法的完整代码:
Parse.Cloud.define("sendPushContactUser", function(request, response) {
// Get parameters
var userID = request.params.userID; // I'm obviously passing this parameter in the method call
// Query
/* ------ query = Any of the above options ------ */
Parse.Push.send({
where: query,
data: {
title : "New message",
alert : "User message",
badge : "Increment",
sound : "soundNotifUserContact.caf",
"params" : {
"pushType" : 2,
"userID" : userID
}
}
}, {
success: function() {
response.success();
},
error: function(error) {
response.error(error);
}
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间和帮助.
mis*_*ink 10
这对我很有用,但您必须在以下情况下将用户与您的安装相关联:
var query = new Parse.Query(Parse.User);
query.equalTo('username', 'Sento');
// Find devices associated with these users
var pushQuery = new Parse.Query(Parse.Installation);
// need to have users linked to installations
pushQuery.matchesQuery('user', query);
Parse.Push.send({
where: pushQuery,
data: {
aps: {
alert: "Test",
sound: ""
}
}
}, {
success: function () {
response.success("Hello world!");
},
error: function (error) {
response.error(error);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6201 次 |
| 最近记录: |