[英]Notification not show in Device tray by using Firebase notification
我使用cordova-plugin-fcm插件为我的IONIC App发送通知。 我需要在我的应用程序中发送通知中的图像,所以我在我的PHP代码中使用notificationOptions 。
没有我的设备托盘中显示的notificationOptions通知,但是当我尝试在我的PHP代码中实现notificationOptions时,Notification不会显示在我的设备托盘中但我进入我的控制台日志:
{"notificationOptions":"{\"largeIcon\":\"https:\\/\\/avatars2.githubusercontent.com\\/u\\/1174345?v=3&s=96\",
\"smallIcon\":\"mipmap\\/icon\",
\"id\":4,\"text\":\"Test message\",
\"title\":\"Title test\",
\"autoCancel\":true}",
"dataValuesToGetWhenClickedOn":"111","wasTapped":false}
PHP代码:
`<?php
$msg = array
(
"dataValuesToGetWhenClickedOn" => 111,
'notificationOptions' => array(
'title' => "Title test",
'id' => 4,
'text' => "Test message",
'smallIcon' => "mipmap/icon",
'largeIcon' => "https://avatars2.githubusercontent.com/u/1174345?v=3&s=96",
'autoCancel' => true
)
);
//print_r($msg); // exit();
$fields = array
(
'to' => "c5clRYgB1vo:APA91bGTlyTQur2S9b5iksc16-T0KzwV9Ein0n0RSafgDBdgxVKjhGQU0BLPmvnJVShCKDhlpeJCpHthmRglQcegT",
'data' => $msg
);
$data = json_encode($fields);
$ch = curl_init("https://fcm.googleapis.com/fcm/send");
$header = array('Accept: application/json','Content-Type: application/json',
"Authorization: key=---Api Key---");
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//curl_exec($ch);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
}
?>`
请帮我。 我想知道我做错了什么。
它解决了我的问题。 如果任何一个面临同样的问题,
请点击链接:
https://github.com/andrehtissot/cordova-plugin-firebase-extended-notification-app-example
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.