I want to send push notification to a specific user using PHP. I know this question is asked many times. But my problem is little different. The push notifications are sent in my case, but to all users even though I have specified it to send push to a particular user,
For that I am saving a unique ID in Parse.com 's installation table whenever user installs app on their android device. This is the code in the android app :
Parse.initialize(this, "XXXX", "XXXX");
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("device_id", Secure.getString(getContentResolver(), Secure.ANDROID_ID));
installation.saveInBackground();
This works fine. I can see the id in the parse's installation table.
Now, this is the php script I'm using to send push notification to specific device id. It does send the push notification, but to all users.
require_once('autoload.php');
use Parse\ParseInstallation;
use Parse\ParsePush;
use Parse\ParseClient;
ParseClient::initialize( 'XXXXXX', 'XXXXX', 'XXXXX' );
function sendPush($query){
$notification = "Test notification!";
$data = array("alert" => $notification);
ParsePush::send(array(
"where" => $query,
"data" => $data
));
}
$query = ParseInstallation::query();
$query->equalTo("device_id", "XXXXXX");
sendPush($query);