【发布时间】:2019-03-15 05:11:21
【问题描述】:
我正在尝试将带有图像内容的推送通知从我的 Web 应用程序发送到 iOS 应用程序。我收到了包含我提供的所有文本和正文消息的通知。但是给定的图像不会显示在通知中。
$url = 'https://fcm.googleapis.com/fcm/send';
$token = "*******************";
$title = "Title";
$body = "This is Test Notification";
$notification = array('title' =>$title , 'text' => $body, 'subtitle'=>'Sub title', 'sound' => 'default', 'badge' => '1', 'category' => 'CustomSamplePush', 'mutable-content'=>'1','urlImageString'=>'imageurl');
$arrayToSend = array('to' => $token, 'notification' => $notification,'priority'=>'high');
$fields = json_encode($arrayToSend);
echo $fields;
$headers = array (
'Authorization: key=' . "***********",
'Content-Type: application/json',
'authKey: keyhere',
'authKeyId:****',
'teamId: ****',
'bundleId: *****',
'endpoint: https://api.development.push.apple.com'
);
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
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, $fields );
$result = curl_exec ( $ch );
echo $result;
curl_close ( $ch );
【问题讨论】:
-
也许这会对你有所帮助。 stackoverflow.com/questions/37839171/…
标签: php ios firebase push-notification apple-push-notifications