I am working on push notifications using Google Cloud Messaging (GCM). I can configure the server and client side after this lesson .
The server runs on Apache Tomcat6.0 (localhost) and the Android emulator in the Google API (API level 17). I have a sender id and an API key. When I start from the emulator, I get a message about the successful connection of the device. After that, after sending a message from the server, the following error is displayed.
com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401()
com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:211)
com.google.android.gcm.server.Sender.send(Sender.java:125)
com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServlet.java:83)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
From other posts, I understand that the wrong API key is the culprit. But in my case, I made sure that I was using the correct option from the API console.
By the way, when I run the emulator, I saw the message "sending regId to the server." What is a registration id? This is not the same as the sender ID; looks like encoded.
Any breakthrough?
EDIT
The issue is finally resolved! Ant incorrectly created the WAR file. Therefore, the API key is unlikely to be updated. It was a nightmare to discover a mistake. Thank you all for your contribution!
source
share