0
我正在通過Firebase服務器從應用服務器向單個設備發送下游消息。我正在使用傳遞給應用服務器的設備reg令牌。應用服務器的代碼是發送下游'數據'消息時'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']]
]);
我從我的Android應用程序收到以下消息(因爲我測試了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"
...
我使用Laravel和狂飲客戶端將郵件傳遞到FCM服務器,我想從我的火力地堡控制檯發送消息給我的模擬器和完成它標誌着消息,但我沒有收到在我的app/emualtor上。這是我的onMessageReceived
方法我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());
}
裏面我不知道什麼是錯我的設置。任何幫助將不勝感激。
您能夠從火力地堡控制檯發送時,收到相同的反應呢? –
您可以嘗試將您的授權標頭調整爲:'Authorization'=>'key ='。 $ skey –
@AL他們沒有來自Firebase的響應,但是在發送消息的日誌中,它顯示了消息的完成狀態 –