Firebaseサーバ経由でアプリケーションサーバからダウンストリームメッセージを単一のデバイスに送信しています。私は、デバイスサーバーに渡されたデバイスのトークンを使用しています。アプリケーションサーバーのコードは、私は私のAndroidアプリから次のようなメッセージを受信してい'500 - ダウンストリームの'データ 'メッセージを送信する際にfirebaseサーバからの内部サーバエラーの応答
$firebase_token = $request->input('token');
$skey = env('FCM_SERVER_KEY');
$client = new Client(['verify' => false]);
$response = $client->request('POST', 'https://fcm.googleapis.com/fcm/send', [
'headers' => [
'Authorization:key=' => $skey,
'Content-Type' => 'application/json'
],
'json' => ['to' => $firebase_token, 'data' => ['message' => 'This is Genius']]
]);
です(私はFCMをテストしていると私は、エミュレータ上の私のアプリに$response
バックを送っています原因。) その同じメッセージ私は郵便配達員に乗っています。
{"message":
"Server error: `POST https:\/\/fcm.googleapis.com\/fcm\/send` resulted in a
`500 Internal Server Error` response:\n
<HTML>\n
<HEAD>\n
<TITLE>Internal Server Error<\/TITLE>\n
<\/HEAD>\n
<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n
<H1>Internal ServerE(truncated...)\n",
"code":500,
"status_code":500,"debug"
...
私はFCMサーバーにメッセージを配信するためにLaravelとがつがつ食うクライアントを使用しています、私は私のFirebaseコンソールから私のエミュレータにメッセージを送信しようとしたし、完成して、メッセージをマークしたが、私はそれを受け取っていません私のアプリ/エミュレータで。これは私がいただきました!間違って私のセットアップとわからないんだけど、私のFirebaseMessagingService
クラス
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
showNotification(remoteMessage.getData().get("message"));
}
private void showNotification(String message) {
Intent i = new Intent(this,MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,i,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("FCM Test")
.setContentText(message)
.setSmallIcon(R.drawable.com_facebook_button_send_icon_blue)
.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0,builder.build());
}
の内側に私のonMessageReceived
方法です。どんな助けもありがとう。
のエミュレータに受け取っていないことを確認してくださいあなたはFirebaseコンソールから送信するときに同じ応答を受信することができますか? –
Authorizationヘッダーを 'Authorization' => 'key ='に調整してみてください。 $ skey –
@ALそのメッセージはfirebaseからの応答ではありませんが、送信されたメッセージのログにはメッセージの完了ステータスが表示されます。 –