cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FCM notification in Arabic coming as ????

0 Kudos
425

FCM notification is not working in arabic from code but while sending the same request from postman, it works as expected. Any help will be much appreciated.

public void testSendSMS() throws IOException {   

 CloseableHttpClient client = HttpClients.createDefault();

   HttpPost httpPost = new HttpPost("https://fcm.googleapis.com/fcm/send");

    log.info("httpPost :: " + httpPost);

   String msg = "تم تقديم الطلب برمز {0} بنجاح";

    JSONObject body = new JSONObject();

   body.put("to", "abc");

   body.put("priority", "high");

    JSONObject notification = new JSONObject();

    notification.put("title", URLEncoder.encode(msg, StandardCharsets.UTF_8));

    notification.put("body", msg);

    notification.put("sound", "default");

    JSONObject data = new JSONObject();

    data.put("Key-1", "JSA Data 1");

    data.put("Key-2", "JSA Data 2");

    body.put("notification", notification);

    body.put("data", data);

   StringEntity entity = new StringEntity(body.toString());

    httpPost.setEntity(entity);

    httpPost.setHeader("Content-type", "application/json");

    httpPost.setHeader("Authorization", "key=yyy");

    log.info("json :: " + json);

    CloseableHttpResponse response = client.execute(httpPost);

    log.info("response :: " + response);

    client.close();
}

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

There was issue with the HTTP client which I was using. Closeable Http had some issue with Arabic content. I tried with Http Request and it was working fine.