I'm currently implementing push notifications to follow user. Apparently, I managed to get push notifications done and responsive well.Hence, The notifications were sent to everyone.I would like to create push notifications and received the notification only by one respective user each time when other users have followed their user account.
I haven't create a pointer that should associate with User. Even If I create, is there any amendments that I should amends on my Cloudcode? I would like to send push notifications to a specific user whenever other user has followed that 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 this ^ is my cloud code in .JS
if (status == false) {
// Create the push notification message.s
let pushMessage = "\(PFUser.currentUser()!.username!) has followed you."
// Submit the push notification.
PFCloud.callFunctionInBackground("FollowersAndFollowing", withParameters: ["message" : pushMessage, "User" : "\(userData.username!)"])
}
and above this is in swift code for frontend.
and the second the url is my class and subclasses of how I setting up