Javascript 谷歌云消息(GCM)数据始终为空

Javascript 谷歌云消息(GCM)数据始终为空,javascript,php,google-cloud-messaging,service-worker,Javascript,Php,Google Cloud Messaging,Service Worker,我正在尝试使用PHP+GCM+服务人员向我的网站(不是应用程序)的用户发送推送通知 当我进入Chrome控制台>>应用程序>>服务人员>>推送时,控制台显示以下内容: Received a push message Test push message from DevTools. Received a push message Uncaught TypeError: Cannot read property 'text' of null 我正在尝试使用PHP脚本完成同样的任务: $msg =

我正在尝试使用PHP+GCM+服务人员向我的网站(不是应用程序)的用户发送推送通知

当我进入Chrome控制台>>应用程序>>服务人员>>推送时,控制台显示以下内容:

Received a push message
Test push message from DevTools.
Received a push message
Uncaught TypeError: Cannot read property 'text' of null
我正在尝试使用PHP脚本完成同样的任务:

$msg = array
(
    'message'   => 'here is a message. message',
    'title'     => 'This is a title. title',
    'subtitle'  => 'This is a subtitle. subtitle',
    'tickerText'    => 'Ticker text here...Ticker text here...Ticker text here',
    'vibrate'   => 1,
    'sound'     => 1,
    'largeIcon' => 'large_icon',
    'smallIcon' => 'small_icon'
);
$fields = array
(
    'registration_ids'  => $ids,
    'data'          => $msg,
);
$headers = array
(
    'Authorization: key=' . $apiKey,
    'Content-Type: application/json'
);
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
推送通知通过,但我得到以下信息:

Received a push message
Test push message from DevTools.
Received a push message
Uncaught TypeError: Cannot read property 'text' of null
我尝试过挖掘
事件的其他属性,但运气不好。我读过的大多数帮助文章都是针对Android的,而不是针对web开发的。我错过了什么