I am using the java servlet with mysql. gcm works but sometimes it's not sending the messages to the device.
this is my code
Sender sender = new Sender(GOOGLE_SERVER_KEY);
String mesg = "some messages";
Message message = new Message.Builder().timeToLive(0)
.delayWhileIdle(true).addData(MESSAGE_KEY, mesg).build();
for (MMemberModel member : memberModels) {
if (member.userid != creatorId) {
try {
try {
// System.out.println("regId: " + member.gcm);
sender.send(message, member.gcm, 1);
} catch (Exception e) {
}
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
if you can send and receive GCM messages sometimes,then there is no error in your project
ya, i also faced that problem i revised my code many times, and also raised a question in stackowerflow. but i cant found any error in my code.
But i received GCM message after 2 days.
its maybe problem with your phone or gcm server
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.