Q:

Not able to send push notifications in cloud code

I have saved all the user's location in the installation object. And i have another object named locationObject which gets updated when the current user sends his current location.When it does, i want to compare his current location with all the other saved locations and send push notifications to the users who are nearby.This is my code but this does not seem to work.
//this code should run when the locationObject is updated
Parse.Cloud.afterSave("locationObject", function (request) {
    var geoPoint = request.object.get("myCurrentLocation");
    var pushQuery = new Parse.Query(Parse.Installation);
    pushQuery.near("significantLocationUpdate", geoPoint);
    pushQuery.limit(100);
    pushQuery.find({
        success: function(results) {
            if (results.length > 0) {
                //console.log(JSON.stringify(results));
                for (i = 0; i < results.length; 1++) {
                    Parse.Push.send({
                        where: pushQuery,
                        data: {
                            alert: "some user is nearby" 
                        }
                    }, {
                        success: function() {
                            console.log("push was successfull")
                        },
                        error: function(error) {
                            console.log("sending push failed")// Handle error
                        }
                    });
                }
            } else {
                console.log("failure");
            }
        },
        error: function (error) {
            console.log("error");
        }
    });
});

A:

This is how i restructured the code.And it works. Thanks to Paulw11
Parse.Cloud.afterSave("locationObject", function (request) {
    var geoPoint = request.object.get("myCurrentLocation");
    var pushQuery = new Parse.Query(Parse.Installation);
    pushQuery.near("significantLocationUpdate", geoPoint);
    pushQuery.limit(100);

    Parse.Push.send({
        where: pushQuery,
        data: {
            alert: "some user is nearby"
        }
    }, {
        success: function() {
            console.log("push was successful");
        },
        error: function(error) {
            console.log("sending push failed")// Handle error
        }
    });
});

