I have a Class "Storybaord" and there are two instances of when to send a Push Notification.
A user likes a post -
[postObject addUniqueObject: [PFUser currentUser] forKey:@"likes"];A user comments on a post -
[postObject addUniqueObject: self.comment forKey:@"comments"];
In my cloud code I use Parse.Cloud.afterSave but I am unsure of how to distinguish between the two, and also determine if they even happen, because there are other occasions of saving the postObject without needing to send a push.
Cloud Code:
Parse.Cloud.afterSave("Storyboard", function(request){
var user = Parse.User.current();
var postUser = request.object.get('userId');
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo ('userId', postUser);
Parse.Push.send({
where: pushQuery,
data: {
alert: "Liked Your Post"
}
}, {
success: function(){
},
error: function(){
}
});
});
postObjectclient-side. Would you like an example answer for a client side or are you dead-set on cloud push?postObjectand if successfully saved, send a push. Then create a separate cloud code function for the comment and send a push within that function. Essentially just like you would client side. No reason to create a conditional statement when it can all be handled in responses or call backsParse.Op.AddUnique()?