【问题标题】:'500 - internal server error' response from firebase server on sending a downstream 'data' messageFirebase 服务器对发送下游“数据”消息的“500 - 内部服务器错误”响应
【发布时间】:2016-10-19 23:27:10
【问题描述】:

我正在通过 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 发送回我在模拟器上的应用程序。) 这是我在 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 客户端将消息传递到 FCM 服务器,我尝试从我的 Firebase 控制台向我的模拟器发送一条消息,它会将消息标记为已完成,但我没有在我的应用程序上收到它/模拟器。这是我的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());
}

我不确定我的设置有什么问题。任何帮助将不胜感激。

【问题讨论】:

  • 从 Firebase 控制台发送时是否能够收到相同的响应?
  • 您可以尝试将 Authorization 标头调整为: 'Authorization' => 'key=' 。 $skey
  • @AL 他们没有来自 firebase 的响应,但在发送的消息日志中显示消息的状态为已完成
  • @Arthur Thompson 谢谢...但我现在得到的回复是空的 []。
  • 响应的状态码是什么?

标签: android laravel firebase firebase-cloud-messaging


【解决方案1】:

确保您的凭据正确无误 由于互联网连接问题,它可能无法接收到模拟器

【讨论】:

    猜你喜欢
    • 2022-10-12
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 1970-01-01
    • 2021-06-03
    • 1970-01-01
    • 2019-02-12
    • 2012-11-26
    相关资源
    最近更新 更多