FireBase开发遇到的问题

  1. 服务端发送中文,客户端收到的是乱码。

服务端发送原先逻辑:
HttpURLConnection connection = getConnection();
connection.setDoOutput(true);
JsonObject fcmMessage;
outputStream.writeBytes(fcmMessage.toString());

修正后的逻辑如下(替换转码函数write由发送string,转为发送bytes):
HttpURLConnection connection = getConnection();
connection.setDoOutput(true);
JsonObject fcmMessage;
String outStr = new Gson().toJson(fcmMessage);
outputStream.write(outStr.getBytes("utf-8"));

你可能感兴趣的:(FireBase开发遇到的问题)