phppushwoosh

send Notification to device using by tag value using pushwoosh


So i am developing an application which requires push notifications and i'm using pushwoosh. but currently i'm stuck on how to send targeted notifications to a device by a tag value.
I am using [http://gomoob.github.io/php-pushwoosh/]
Any help will be appreciated. thanks

$filter = '';
$request = CreateTargetedMessageRequest::create()
->setContent($options['body'])
->setData(
    [
        'custom' => 'json data'
    ]
)
->setDevicesFilter($filter);
$pushwoosh->createTargetedMessage($request);

what i want is the value for the filter


Solution

  • I ended up solving it myself. I used the setCondition() method to specify the tag name and value for what i wanted.

    $request = CreateMessageRequest::create()
        ->addNotification(Notification::create()
    
            ->setContent($options['body'])
            ->setConditions([
                IntCondition::create('userId')->eq($user_id)
            ]));
    
    
    // Call the REST Web Service
    $response = $pushwoosh->createMessage($request);