Parse.Cloud.define('sendKeywordNotifications', function (request, response) { // THIS METHOD NO LONGER WORKS // Parse.Cloud.useMasterKey();
var itemSearchStringArray = request.params.itemSearchStringArray; var fullMessage = request.params.fullMessage; var objectIdOfUserWhoPostedTheitem = request.params.objectIdOfUserWhoPostedTheItem; console.log("XXXXXXXX"); console.log(itemSearchStringArray); console.log("about to send some notifications"); var currentUserPointer = Parse.User.createWithoutData(objectIdOfUserWhoPostedTheitem); console.log(currentUserPointer);
var userQuery = new Parse.Query(Parse.User); userQuery.notEqualTo("objectId", objectIdOfUserWhoPostedTheitem); userQuery.notEqualTo("following", currentUserPointer); userQuery.equalTo("notificationWhenFriendPostsNewItem", true); userQuery.containedIn("notificationsArray", itemSearchStringArray); console.log(userQuery); console.log("----------"); var installationQuery = new Parse.Query(Parse.Installation); installationQuery.matchesQuery("user", userQuery); console.log(installationQuery); console.log("----------");
Parse.Push.send({ where: installationQuery, data: { alert: fullMessage, sound: "default" } }, { useMasterKey: true, success: function() { console.log("the push was successful"); // Push was successful }, error: function(error) { console.log(error); // Handle error } });
response.success("overall function successful"); });
XXXXXXXX
[ 'test', 'chair', 'hello' ]
about to send some notifications
ParseUser { _objCount: 176, className: '_User', id: 'LUbRhX9iY1' }
ParseQuery {
className: '_Installation',
_where: { user: { '$inQuery': [Object] } },
_include: [],
_limit: -1,
_skip: 0,
_extraOptions: {} }
ParseQuery {
className: '_User',
_where:
{ objectId: { '$ne': 'LUbRhX9iY1' },
following: { '$ne': [Object] },
notificationWhenFriendPostsNewItem: true,
notificationsArray: { '$in': [Object] } },
_include: [],
_limit: -1,
_skip: 0,
_extraOptions: {} }
----------
----------
the push was successful
{ following: { '$nin': [Object] },
notificationsArray: { '$in': [Object] } },
Parse.Cloud.define('sendKeywordNotifications', function (request, response) { // THIS METHOD NO LONGER WORKS // Parse.Cloud.useMasterKey();
var itemSearchStringArray = request.params.itemSearchStringArray; var fullMessage = request.params.fullMessage; var objectIdOfUserWhoPostedTheitem = request.params.objectIdOfUserWhoPostedTheItem; console.log("XXXXXXXX");
console.log("about to print the itemSearchStringArray"); console.log(itemSearchStringArray); var currentUserPointer = Parse.User.createWithoutData(objectIdOfUserWhoPostedTheitem); console.log("about to print the currentUserPointer");
console.log(currentUserPointer);
var userQuery = new Parse.Query(Parse.User); userQuery.notEqualTo("objectId", objectIdOfUserWhoPostedTheitem);
//userQuery.notEqualTo("following", currentUserPointer);
userQuery.equalTo("notificationWhenFriendPostsNewItem", true); userQuery.containedIn("notificationsArray", itemSearchStringArray);
console.log("about to print the userQuery");
console.log(userQuery); console.log("----------"); var installationQuery = new Parse.Query(Parse.Installation); installationQuery.matchesQuery("user", userQuery);
console.log("about to print the installationQuery");
console.log(installationQuery); console.log("----------");
Parse.Push.send({ where: installationQuery, data: { alert: fullMessage, sound: "default" } }, { useMasterKey: true,
success: function() { console.log("the push was successful"); // Push was successful response.success("overall function successful"); }, error: function(error) { console.log(error); // Handle error response.error("error: " + error); } });
//response.success("overall function successful"); });
ERR! cannot find vaild connection for ### <-- (i replaced the long number here, not sure if privacy issue...)
parse-server-push-adapter APNS
the push was successful
ERR! cannot find vaild connection for ### <-- (i replaced the long number here, not sure if privacy issue...) parse-server-push-adapter APNS
XXXXXXXX [ 'sets', 'drawers' ] about to print the itemSearchStringArray about to print the userQuery ParseUser { _objCount: 150, className: '_User', id: 'LUbRhX9iY1' } about to print the currentUserPointer ParseQuery { className: '_Installation', _where: { user: { '$inQuery': [Object] } }, _include: [], _limit: -1, _skip: 0, _extraOptions: {} } ---------- about to print the installationQuery ParseQuery { className: '_User', _where: { objectId: { '$ne': 'LUbRhX9iY1' }, notificationWhenFriendPostsNewItem: true, notificationsArray: { '$in': [Object] } }, _include: [], _limit: -1, _skip: 0, _extraOptions: {} } ---------- the push was successful