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
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".
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
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);
}
});
});
This code sends push to all users.
Please help
To deliver push notifications to app customers, marketers launch the campaign using marketing partner tools like MoEngage. The marketer's campaign is then sent to cloud messaging platforms such as FCM, and APNS. These messaging platforms deliver the notification from the marketing partner to the end customer's device.
Configure custom push notifications in the Dashboard To do so, navigate to the Settings > App Settings page, select the app you'd like to set up custom push notifications for, then scroll down to the push notifications section. Change the option under 'Select push notification server' to 'Custom push notifications'.
This can be a solution:
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);
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With