非ラテン文字セットを使用して Android と iOS の両方に通知を送信しようとしています。
Android から iOS に非ラテン文字セットを使用してメッセージを送信すると、iPhone でメッセージが「????」と表示されることに気付きました。iOS と Android の Java サーバー側は同じなので、 Android ハンドセットからのリクエスト、iOS から iOS への通知メッセージは正常に機能します。
以下は、ネットワーク接続を開いてリクエストを送信するために使用しているコードです。問題がなければお知らせください。
byte[] bytes = body.getBytes(/*"UTF-16"*//*"ISO-8859-1"*/"UTF-8");
        HttpURLConnection conn = null;
        StringBuilder stringBuilder = new StringBuilder();
        try {
            conn = (HttpURLConnection) url.openConnection();//conn.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            conn.setFixedLengthStreamingMode(bytes.length);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded;charset=UTF-8");
            // post the request
            OutputStream out = conn.getOutputStream();
            out.write(bytes);
            out.close();
            // handle the response
            int status = conn.getResponseCode();
            if (status != 200) {
                Log.d("send message", "Coud Send Message, No Internet Connection Avilable.");
                throw new IOException("Post failed with error code " + status);
            }
            InputStream in = new BufferedInputStream(conn.getInputStream());
            // readStream(in);
            int b;
            while ((b = in.read()) != -1) {
                stringBuilder.append((char) b);
            }