I am trying to get parse push notifications to work using cloud code. Here is what I have done:
In my AppDelegate.swift
let currentInstallation = PFInstallation.current()
currentInstallation?["user"] = PFUser.current()!.username!
Then I call the following cloud code function when a users username is mentioned
// Create the push notification messages
let pushMessage = "\(PFUser.current()!.username!) has mentioned you in a post."
// Submit the push notification.
PFCloud.callFunction(inBackground: "mentions", withParameters: ["message" : pushMessage, "User" : "\(word)"])
Here is my Cloud code
Parse.Cloud.define("mentions", function(request,result){
var message = request.params.message;
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo("user",request.params.User);
Parse.Push.send({
where: pushQuery,
data : {
alert: message,
badge: "Increment",
}
}, {
success: function(result) {
console.log(JSON.stringify(result));
response.success(result);
},
error: function(error) {
console.error(JSON.stringify(error));
response.error(error.message)
}
useMasterKey: true
});
});
I then get error 141 when checking the logs