簡體   English   中英

發送下游“數據”消息時,來自firebase服務器的“500 - 內部服務器錯誤”響應

[英]'500 - internal server error' response from firebase server on sending a downstream 'data' message

我正在通過Firebase服務器從應用服務器向單個設備發送下游消息。 我正在使用傳遞給apps服務器的設備reg令牌。 應用服務器代碼是

    $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發送回我在模擬器上的應用程序。)它與Postman上的相同消息。

{"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和Guzzle Client將消息發送到FCM服務器,我嘗試從Firebase控制台向我的模擬器發送消息,並將消息標記為已完成,但我沒有在我的app / emualtor上收到消息。 這是我的FirebaseMessagingService類中的onMessageReceived方法

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());
}

我不確定我的設置有什么問題。 任何幫助將不勝感激。

確保您的憑據正確,因為互聯網連接問題,可能無法接收到模擬器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM