' 500 - 内部服务器错误' firebase服务器在发送下游数据时的响应'消息

时间:2016-10-19 23:27:10

标签: android laravel firebase firebase-cloud-messaging

我通过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客户端将消息发送到FCM服务器,我尝试从Firebase控制台向我的模拟器发送消息,并将消息标记为已完成,但我没有收到消息在我的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());
}

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

1 个答案:

答案 0 :(得分:0)

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