0

我正在使用以下 php sdk 来生成推送梁推送通知。但是 sdk 文档中没有提供有关如何发送数据/有效负载的信息。通知是正确发送的 bean,但我无法发送数据:请指导我如何发送数据:它在光束控制台中显示 hasData 为 false,请检查: 在此处输入图像描述

我正在使用的php sdk:https ://github.com/pusher/push-notifications-php

我的代码如下所示:

$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
                         ],
                    ],
                ]
            );
4

1 回答 1

0

我搞定了,我们可以通过以下方式传递数据:

$publishResponse = $pushNotifications->publishToInterests(
  ["donuts"],
  [
    "apns" => [
      "aps" => [
        "alert" => "Hello!",
      ],
    ],
    "fcm" => [
      "notification" => [
        "title" => "Hello!",
        "body" => "Hello, world!",
      ],
      "data" => [                      // <==== pass data here
         "name" => "adam",
         "type" => "user",
      ],
    ],
  ]
);
于 2021-01-23T16:13:54.733 回答