javascript - Parse Cloud: Send a notifications to a specific user -
i'm implementing push notifications follow user. apparently, managed push notifications done , responsive well.hence, notifications sent everyone.i create push notifications , received notification 1 respective user each time when other users have followed user account.
i haven't create pointer should associate user. if create, there amendments should amends on cloudcode? send push notifications specific user whenever other user has followed user.
eg: test 1 followed you.
parse.cloud.define("followersandfollowing", function(request,result){ var query = new parse.query(parse.user); var message = request.params.message; var pushquery = new parse.query(parse.installation); query.equalto('userlink',request.params.user); parse.push.send({ where: pushquery, data : { alert: message, badge: "increment", sound: "", } }, { success: function(result) { console.log(json.stringify(result)); response.success(result); }, error: function(error) { console.error(json.stringify(error)); response.error(error) } }); });
above ^ cloud code in .js
if (status == false) { // create push notification message.s let pushmessage = "\(pfuser.currentuser()!.username!) has followed you." // submit push notification. pfcloud.callfunctioninbackground("followersandfollowing", withparameters: ["message" : pushmessage, "user" : "\(userdata.username!)"]) }
and above in swift code frontend.
and second url class , subclasses of how setting up
use cloud code beforesave trigger on installation
class keep user
pointers date.
// make sure installations point current user parse.cloud.beforesave(parse.installation, function(request, response) { parse.cloud.usemasterkey(); if (request.user) { request.object.set("user", request.user); } else { request.object.unset("user"); } response.success(); });
you may want use aftersave trigger on follow class send out push notification instead of calling cloud function. without knowing structure of class or how have implemented follower/following scheme it's hard give further information.
Comments
Post a Comment