I have tried sending notification JSON
to GCM
server using GCM-SERVER jar in plain text format and succeed but unable to find how can send the request in json format using same jar... please provide any document link for gcm-server jar or any help will be appreciated...
code is following that i have tried in plain text format ...
import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
private static final String GOOGLE_SERVER_KEY = "AIzaSyCIiiADfyS5dDuKk65Auk1_qhr-vruv2-0";
static final String MESSAGE_KEY = "message";
public static boolean PushNotificationsInPlainText(String type, String device,String content) {
Result result = null;
String regId = "APA91bGpY6NdmK22dCId1LIyHLY3RKYmrFu3A5hyYHqNVvtP1puS0ITLC73fZ3XBgZqnt_AHYiH8C9Rkk37yazTCLkw0mJymxZUPZTtICtIJY5drM_ZOzpFTF71V0TkiHCQ-k3QGV7bv";
Sender sender = new Sender(GOOGLE_SERVER_KEY);
Message message = new Message.Builder().timeToLive(30)
.delayWhileIdle(true).addData(MESSAGE_KEY, content).build();
System.out.println("regId: " + regId);
try {
result = sender.send(message, regId, 1);
} catch (IOException e) {
System.out.println(result);
e.printStackTrace();
}
return true;
}