android - How can i send push notification on any item update event in parse.com -
i using parse application
i have 1 fragment on user have write article , save on parse not approve
when admin approve user filed want send push notification automatically user particular article approved message
how can implement things..?
parse.cloud.aftersave("data", function(request) {var dirtykeys = request.object.dirtykeys();for (var = 0; < dirtykeys.length; ++i) { var dirtykey = dirtykeys[i]; if (dirtykey === "name") { //get value data object var username = request.object.get("name"); //set push query var pushquery = new parse.query(parse.installation); pushquery.equalto("name",username); //send push message parse.push.send({ where: pushquery, data: { alert: "name updated", sound: "default" } },{ success: function(){ response.success('true'); }, error: function (error) { response.error(error); } }); return; } } response.success();});
if matter of hitting "approve", create cloud code function "approve article" called admin tapping approve button. function sets approve status , calls function (still in cloud code) sending push message user.
more on cloud code functions: https://parse.com/docs/cloudcode/guide#cloud-code-cloud-functionshttps://parse.com/docs/cloudcode/guide#cloud-code-cloud-functions
alternatively approve button can change status , save document, , aftersave()
function in cloud code can handle push. less clear, though, since aftersave()
function called when record saved, , need check status , send push if article has been approved.
Comments
Post a Comment