I'm trying to call a cloud code function in Parse but whenever it gets called I get the following error, but have no idea why it is invalid:
2019-04-30T11:0 1:44.020Z - Invalid function: "pushTenFTC"
Cloud Code:
Parse.Cloud.define("pushTenFTC", async (request) => {
var query = new Parse.Query(Parse.Installation);
let userId = request.params.userId;
query.equalTo('userId', userId);
Parse.Push.send({
where: query,
data: {
alert: "Fitcoins Gifted!",
title: userId + " sent you 10 Fitcoins!"
}
}).then(function() {
// Push was successful
}, function(error) {
// Handle error
});
Called in Swift:
var params = [AnyHashable: Any]()
params["userId"] = feedElements[sender.tag].objectID
PFCloud.callFunction(inBackground: "pushTenFTC", withParameters: params) { (response, error) in
if let error = error {
//error handling
return
}
//Success
}
It seems you are missing
});
at the end of the function and yourmasterKey
is also required to send push notifications.The whole function should look like this...