【发布时间】:2020-03-12 14:17:26
【问题描述】:
推送通知中的图标出现问题。
我正在使用 PHP 将 推送通知 发送到 android 应用,以及我使用 Ionic 4 和 Angular 8 创建的 android 应用
下面是 PHP 代码
<?php
error_reporting(E_ALL);
ini_set("display_errors", true);
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'xyz' );
$registrationIds = array("");
$_POST['title'] = "Title goes here.";
$_POST['subtitle'] = " ";
$_POST['ticket_text'] = " ";
$_POST['message'] = "Write here your message.";
// prep the bundle
$msg = array
(
'message' => $_POST['message'],
'title' => $_POST['title'],
'subtitle' => $_POST['subtitle'],
'tickerText' => $_POST['ticket_text'],
'vibrate' => 1,
'alert'=> 'true',
'badge'=> true,
'sound'=> 'true',
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
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 );
curl_close( $ch );
echo $result;
exit;
【问题讨论】: