解析来自云code发送推送通知到特定的用户 [英] Parse Sending push notification to specific user from Cloud code
问题描述
我要发送的解析云code推送通知给特定用户。 所以,我已经创建了我的语法分析表的安装类用户部分,我节省了用户对象ID有这样我就可以通过定位标识的用户,并从云code发送推送。 https://www.dropbox.com/s/dvedyza4bz3z00j/userObjec.PNG ?DL = 0
I want to send a push notification from parse cloud code to a specific user. So i have created a user section in installation class of my parse table and i save the user object id there so i can target the user by id and send push from cloud code. https://www.dropbox.com/s/dvedyza4bz3z00j/userObjec.PNG?dl=0
从parse.com这是很简单的事,我没有像这样与条件 https://www.dropbox.com/s/1mb3pb2izb0jlj9/pushs.PNG ?DL = 0
From parse.com it is very simple to do, i did it like this with condition https://www.dropbox.com/s/1mb3pb2izb0jlj9/pushs.PNG?dl=0
但我想做的是当用户在课堂上我的课是票,增加了新的对象发送推送通知。
But what i want to do is to send a push notification when a user adds new object in the class my class is "Ticket".
本类有ACL启用。 我想要做的是非常简单的发送推它通过云code
This class has ACL enabled. What i want to do is very simple send push to the user which created the object through cloud code
下面是我的云code
Here is my cloud code
Parse.Cloud.afterSave("Ticket", function(request) {
var pushQuery = new Parse.Query(Parse.Installation);
Parse.Push.send({
where: pushQuery,
data: {
alert: "New Ticket Added",
sound: "default"
}
},{
success: function(){
response.success('true');
},
error: function (error) {
response.error(error);
}
});
});
这code发送推送到所有用户。
This code sends push to all users.
请帮忙
推荐答案
这可能是一个解决办法:
Parse.Cloud.afterSave( "Ticket", function(request) {
//Get value from Ticket Object
var username = request.object.get("username");
//Set push query
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo("username",username);
//Send Push message
Parse.Push.send({
where: pushQuery,
data: {
alert: "New Ticket Added",
sound: "default"
}
},{
success: function(){
response.success('true');
},
error: function (error) {
response.error(error);
}
});
});
这篇关于解析来自云code发送推送通知到特定的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!