FCM的trustAnchors参数必须是非空的

时间:2017-03-02 17:56:41

标签: java android firebase push-notification firebase-cloud-messaging

我正在尝试通过Firebase发送推送通知。我使用以下代码发送数据消息:

IllegalArgumentException: Can't get Kerberos realm

这是我为数据消息编写的Json:

    String authKey = <My Server key>;
    String FMCurl = "https://fcm.googleapis.com/fcm/send";

    URL url = new URL(FMCurl);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    conn.setUseCaches(false);
    conn.setDoInput(true);
    conn.setDoOutput(true);

    conn.setRequestMethod("POST");
    conn.setRequestProperty("Authorization", "key=" + authKey);
    conn.setRequestProperty("Content-Type", "application/json");

    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(data.toString());
    wr.flush();
    wr.close();

    int responseCode = conn.getResponseCode();

当它点击{ "data": { "fromUserId": "346", "toUserId": "343", "message": "checkLoginStatus", "messageId": "1488475905411" }, "to": "<Firebase Token of the android device>" } 时,我收到以下错误:

conn.getOutputStream()

我做错了什么?提前谢谢。

0 个答案:

没有答案