1

I have a custom "Installation" called "organization_id"

When I run the filter from the Admin Panel to send a push with "organization_id" of 1, it works, however when I use the PHP SDK, see code, it gives me "You sent this push notification to 0 recipients."

ParseClient::initialize($app_id, $rest_key, $master_key);
$query = ParseInstallation::query();
$query->equalTo("organization_id", "1");
$data = array("alert" => "Name : Message");

ParsePush::send(array(
    'data' => $data,
    'where' => $query
));

The "full target" for the push that worked, from the admin panel is

Targeting : organization_id is "1"
            deviceType is "android"
Full target : { "organization_id": "1", "deviceType": "android" }

For the one that doesn't work, from the PHP SDK, is:

Targeting : where advanced operator (organization_id "1")
            deviceType is any of "android", "winphone" or "js"
Full target : { "where": { "organization_id": "1" }, "deviceType": { "$in": [       "android", "winphone", "js" ] } }
  • Have you found any solutions yet? I am having the same issue http://stackoverflow.com/questions/33619335/send-push-notification-to-specific-user-using-parse – Ashish Tanna Nov 11 '15 at 23:12

2 Answers2

0

The problem seems to be the type of the variable you are passing in. I assume the field organization_id is of type Number but you are passing in a string.

I tried it real quick making use of the badge column in the Installation class, it is of type Number, when passing in a string for the where constraint, it does not work. Passing in an integer works just fine.

I am pretty sure this is your problem.

Björn Kaiser
  • 9,882
  • 4
  • 37
  • 57
0

The issue was with Parse PHP SDK 1.0.0. This issue is fixed with an update to 1.0.1. My guess was in ParsePush.php on line 42 it was

$data['where'] = $data['where']->_getOptions();

And now it's

$data['where'] = $data['where']->_getOptions()['where'];