Firebase云消息传递-PHP Rest API不适用于iOS

Firebase云消息传递-PHP Rest API不适用于iOS,php,push-notification,firebase-cloud-messaging,Php,Push Notification,Firebase Cloud Messaging,我使用下面给出的PHP代码通过Firebase云消息发送带有自定义负载的通知。它适用于Android,但不适用于iOS 但是,我能够接收firebase云消息控制台发送的通知。请告知 public function send_notification($registatoin_ids, $message, $title, $sound, $purpose) { // Set POST variables $url = 'https://fcm.googleapis.com/

我使用下面给出的PHP代码通过Firebase云消息发送带有自定义负载的通知。它适用于Android,但不适用于iOS

但是,我能够接收firebase云消息控制台发送的通知。请告知

public function send_notification($registatoin_ids, $message, $title, $sound, 
$purpose) 
{

    // Set POST variables
    $url = 'https://fcm.googleapis.com/fcm/send';

    $fields = array(
        'registration_ids' => $registatoin_ids,
        'data' => array(
                        "for" => $purpose,
                        "id" => strtotime("now"),
                        "message" => $message,
                        "title" => $title,
                        "sound" => $sound,
                         "vibrate" => 1,
                        "date" => date("D d, M Y h:i A"),
                        "priority"=>'high',
                        "content_available"=>false
                        ),
        'time_to_live' => 600,
    );

    $headers = array(
        'Authorization: key=' . FCM_API_KEY,
        'Content-Type: application/json'
    );
    // Open connection
    $ch = curl_init();

    // Set the url, number of POST vars, POST data
    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Disabling SSL Certificate support temporarly
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

    // Execute post
    $result = curl_exec($ch);
    if ($result === FALSE) {
        die('Curl failed: ' . curl_error($ch));
    }

    // Close connection
    curl_close($ch);
    return $result;
}

Android和iOS处理推送通知的方式不同。虽然Android只有在提供
数据
标签时才会从后台唤醒,但iOS设备需要
通知
标签来处理应用程序处于后台时收到的通知。

当你说“它适用于Android,但不适用于iOS”时您是指从后台唤醒应用程序吗?如果您已经尝试使用
通知
标记发送iOS设备消息,那么您的问题可能是如何处理
AppDelegate
文件中的消息。编辑您的问题,添加您在iOS中尝试过的消息结构,并添加您在
AppDelegate
中使用的代码,以在iOS中处理消息。我也尝试过使用通知标签,使用标题和消息键,但仍然无法接收通知。@MudassirShah::编辑您的问题,添加您在iOS中尝试过的消息结构,并添加您在
AppDelegate
中用于在iOS中处理消息的代码。