Raudius / Pushraven

A simple Java library to interface with Firebase Cloud Messaging (FCM) API. Pushraven allows you to push notifications to clients in very few lines of code.
MIT License
78 stars 34 forks source link

Issue in sending notification with utf-8 title and body #3

Closed rezaep closed 8 years ago

rezaep commented 8 years ago

Hi Already after sending a notification which has utf-8 title and body ( i test sending Persian characters ), in client side characters are not encoded correctly. I modified a part of code in Pushraven class and i fixed it.

// Send POST body
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());

wr.writeBytes( n.toJSON() );

wr.flush();
wr.close();

changed to:

 // Send POST body
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));

writer.write(n.toJSON());
writer.close();
wr.close();

 wr.flush();
wr.close();
Raudius commented 8 years ago

Thanks!

I added a pre release version 1.0.1 jar to the source files. Still not under releases because I have not had a chance to fully test it.