I am making an API for sending notification to android mobile using Google cloud. I have done this on servlet,
MulticastResult result = null;
try {
String share = "APA91bERgNUDKD80bGsF-10vnbCbZxLbE6yL1HHLqtJK7jbLvXTDYa0R3urM7cL3R-TqeWOEZTdzSl45oVsNcOHU-Ykt8RjgJsepOJ96wHtSjRhlkqM5vQMAFzGdeGjsYU3bVFwEbtWLcHQEkXXg6RTeyrKAael-_HM_1uJPzCQvW_Wu9K5Q05A";
String userMessage = "Hello";
String GOOGLE_SERVER_KEY = "AIzaSyBojZP8afz3MdUcHYoQeRsgvh3nI2wfv50";
Sender sender = new Sender(GOOGLE_SERVER_KEY);
String MESSAGE_KEY = "message";
Message message = new Message.Builder().timeToLive(30).delayWhileIdle(true).addData(MESSAGE_KEY, userMessage).build();
List<String> regIdList = new ArrayList<String>();
regIdList.add(share);
result = sender.send(message, regIdList, 1);
request.setAttribute("pushStatus", result.toString());
}
catch(Exception ioe){
ioe.printStackTrace();
}
But it gives error that, cannot retry due to server authentication, in streaming mode. I can't figure out what this error is. Is this the right method for notification or is there another method present for this?
0 comments:
Post a Comment