Firebaseに移行した後、Firebaseコンソールを使用して通知を送信することが正常に動作しましたが、特定の時刻に毎日通知が必要なため、firebaseコンソールを使用する代わりに以前のcronジョブを使用して通知を毎日送信します。 https://android.googleapis.com/gcm/send
をhttps://fcm.googleapis.com/fcm/send
に変更しましたが、私のデバイスは通知を受け取りません。サーバー側でfirebaseクラウドメッセージングを実装する方法は?
これを解決する方法はありますか?それとも、私は何かが欠けてしまった? GCMをまだ使用しているデバイスでは、私のcronの仕事はうまくいきます。ここで
は私のコードは別に、以下のURLを変更することから
function sendNotificationFCM($apiKey, $registrationIDs, $messageText,$id) {
$headers = array(
'Content-Type:application/json',
'Authorization:key=' . $apiKey
);
$message = array(
'registration_ids' => $registrationIDs,
'data' => array(
"message" => $messageText,
"id" => $id,
),
);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://fcm.googleapis.com/fcm/send',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($message)
));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
@McAwesomville私がhttpsで読んだからです:// firebase。 google.com/docs/cloud-messaging/server#implementing-http-connection-server-protocolメッセージを送信するには、アプリケーションサーバーi POSTリクエストを送信します。例: 'https.fcm.googleapis.com/fcm/send' – natsumiyu
@McAwesomvilleは何を使うのか分かりませんが、私はそれを試してみます。 – natsumiyu
私は周りを見回してみましょう何か: –