简体   繁体   中英

InvalidRegistration when sending message to device via GCM

I am trying to send a GCM message to my device, and for some reason, on the server, the getErrorCodeName() is returning InvalidRegisration.

I basically implemented the example from google, and registered, and sent the registration ID to the log, and wholesale copied it from the log to the code on the server where I am trying to do the send.

Any idea on what could be wrong?

        Result result = sender.send(message,"foo", 1);
        System.out.println("Message sent: "+result.getErrorCodeName());

I have double checked to see that logcat is not truncating the value being printed out, and it isn't. I logged the length of the registration id and matched it with the length of the string/regid I'm using on the server when I am sending the notification.

Not sure what's going on.

The send() method has to follow this format:

send (Message message, String registrationId, int retries)

Looking at your snippet of code, you will need to revise the second parameter.

If you had just replaced the actual registration ID for privacy reasons, I would suggest checking that you are sending the registration ID completely. As mentioned here , it could have been truncated or altered in transit from your client device to your 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM