推送通知图像未显示在iOS设备上,但显示在Android上

时间:2020-02-07 06:07:10

标签: php ios laravel firebase-cloud-messaging

我已经在laravel + PHP + FCM中实现了推送通知逻辑,在Android设备上通过IMAGE接收通知。在iOS中,每次都会收到通知,但不会显示图像。

是我需要传递的任何属性。以下是我的对象。

public function sendNotification($id, $article_heading, $article_image, $article_category, $notification_text, $fcms) {
    $registrationIds = $fcms;

    $serverKey = '****';

    $headers = array();
    $headers[] = 'Content-Type: application/json';
    $headers[] = 'Authorization: key='. $serverKey;

    $data['click_action'] = 'FLUTTER_NOTIFICATION_CLICK';
    // dd($id);
    $data['article_id'] = $id;
    $data['android_channel_id'] = 'myapp';
    // dd($data);
    $url = "https://fcm.googleapis.com/fcm/send";
    $title = "";
    $body = $notification_text;

    $notification = array('title' =>$title, 'body' => $body, 'image' => $article_image, 'sound' => 'default', 'badge' => '1', 'alert'=>'1', "content_available"=>"1");


    $arrayToSend = array('notification' => $notification, 'data'=> $data, 'priority'=>'high','content_available' => True, 'registration_ids' => $registrationIds, "apns" => array("headers" => ["apns-priority"=>10], "payload"=> array("aps"=>["sound"=>"default"])));

    $json = json_encode($arrayToSend);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
    curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //Send the request
    $result = curl_exec($ch);

    $response["status"]="success";
    return $response;
}

0 个答案:

没有答案