0

I am using following php sdk for generating pusher beam push notification. but there is not information provided in the sdk docs on how to send data/payload along with it. the notification is bean sent correctly but I am unable to send data: please guide me how we can send the data: it is showing hasData as false in beam console, please check: enter image description here

php sdk i am using : https://github.com/pusher/push-notifications-php

my code look like this:

$pushNotification = new PushNotifications([
                'instanceId' => env('BEAM_INSTANCE_ID'),
                'secretKey' => env('BEAM_PRIMARY_KEY')
            ]);
            $pushNotification->publishToInterests(
                ['message-notification'],
                [
                    "apns" => [
                        "aps" => [
                            "alert" => "Message Received",
                        ],
                    ],
                    "fcm" => [
                        "notification" => [
                            'title' => 'some title',
                            'body' => 'some body',
                            'data' => 'some data', //passing data here but not working
                         ],
                    ],
                ]
            );
Qasim Nadeem
  • 597
  • 4
  • 17

1 Answers1

0

I got it working, we can pass data in following way:

$publishResponse = $pushNotifications->publishToInterests(
  ["donuts"],
  [
    "apns" => [
      "aps" => [
        "alert" => "Hello!",
      ],
    ],
    "fcm" => [
      "notification" => [
        "title" => "Hello!",
        "body" => "Hello, world!",
      ],
      "data" => [                      // <==== pass data here
         "name" => "adam",
         "type" => "user",
      ],
    ],
  ]
);
Qasim Nadeem
  • 597
  • 4
  • 17