I am currently using back4app as my parse host.
I have push notifications correctly sending to the required devices when using Parse.Cloud.afterSave. So as I can rule out server setup issues.
I want to also detect when a row is deleted and I believe I can do this by using the Parse.Cloud.beforeDelete function.
My Parse.Cloud.beforeDelete function looks like the following
Parse.Cloud.beforeDelete("CallSession", function(request, response) {
query = new Parse.Query("CallSession");
query.equalTo("callerID", request.object.get('callerID'));
var recieverID = request.object.get('receiverID');
var sessionID = request.object.get('sessionID');
var subscriberToken = request.object.get('subscriberToken');
var publisherToken = request.object.get('publisherToken');
var callerTitle = request.object.get('callerTitle');
var callerImageURL = request.object.get('callerImageURL');
var isVideoCall = request.object.get('isVideo');
var pushID = request.object.get('pushID');
var callerID = request.object.get('callerID');
var callerObjectID = request.object.get('callerObjectId');
var publicFigureObjectID = request.object.get('publicFigureObjectId');
Parse.Push.send({
where: query, // Set our Installation query
data: {
"content-available" : 1,
"sessionID" : sessionID,
"subscriberToken" : subscriberToken,
"publisherToken" : publisherToken,
"callerTitle" : callerTitle,
"callerID" : callerID,
"callerObjectId" : callerObjectID,
"publicFigureObjectId" : publicFigureObjectID,
"callerImageURL" : callerImageURL,
"isVideo" : isVideoCall,
"pushID" : "endCall"
}
},{success: function() {
return response.success('endcall Sent OK');
},
error: function(error) {
console.log('Push AfterSave Error = ' + error);
return response.success(error);
},
useMasterKey: true
});
});
The server logs are showing that the beforeDelete is being triggered however the push is not sending to the device.
Would anybody know what I'm doing wrong with the above cloud function?
thanks in advance
Thomas Richardson
For what I could check the amount of data that you're inserting within the Parse.Push.send() exceed the preset from Parse Server basic settings. As you can check in their Documentation:
If you want to send more than just a message, you can set other fields in the data dictionary. There are some reserved fields that have a special meaning.
This can be improved and specific needs can be added however, as you may check the Documentation, you'll need to configure your app to have those settings and handle what the Cloud Code can't.
Another thing that you might need to consider is checking if the results of your query matches what you desire to use in the subsequent lines of code by debugging it (adding some logs showing the content of your query response should be enough).