on 2023 Jan 09 12:44 PM
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();
}
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.