2
通知でアプリを作成しようとしています。通知はphpファイルからfirebaseに送信し、次にデバイスに送信する必要があります。最初はfirebase consoleで送信しようとしましたが、完璧に動作します。しかし、私はPHPを使用してnotificaionを送信しようとすると、私は問題があります。それは正常に送信されたが、私は通知を受け取っていないと言う。通知を送信するために私のPHPがあります:ios-firebaseで通知を送信する
<?php
function send_notification ($tokens, $message)
{
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'to' => $tokens,
'data' => $message
);
$headers = array(
'Authorization:key = my api key',
'Content-Type: application/json'
);
$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_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
return $result;
}
$data = array("alert" => "How it is going today");
$token = "fJVM7YrWGQg......";
$message = array("message" => " FCM PUSH NOTIFICATION TEST MESSAGE");
$message_status = send_notification($token, $message);
echo $message_status;
>
それを修正するために私が検索しました?。しかし何も助けなかった。
こんにちは@MRustamzadeあなたは私があなたのアプリ内でそれをどう扱うか教えてください。ありがとう、私に知らせてください。 –
@AvinashMishra私はここでそれをしました:https://firebase.google.com/docs/cloud-messaging/ios/client – MRustamzade