Google Cloud Messaging (Gcm) with Local Device Groups on Android Gives Http Error Code 401

Google Cloud Messaging (GCM) with local device groups on Android gives HTTP Error code 401

Found the trick: you are using a google account to take the id_token, you need to use EXACTLY the email as notification_key_name. So if you are using foo@gmail.com, you need to use this address as notification_key_name.

Error while running GCM sample app

I had a similar problem. In developers guidelines the instructions is:

When the sample application loads on your device, run the following
gradle command to send a notification to all registered app instances:

Linux/Mac:

./gradlew run -Pmsg="message"

Windows:

.\gradlew.bat run -Pmsg="message"

But each time I run the gradle command the same error happened.

Finally instead of running the gradle command, I run GcmSender.java itself in android studio and it worked correctly and notifaction appeared on my device.

Note that before running GcmSender.java you must edit run configuration and pass your message as Program arguments.

Is it OK to use the SERVER_API key on a client, and is it possible to send a GCM message to a device group without using the SERVER_API key?

Don't use the SERVER_API key on your client!

This key is a secret, and will not be obfuscated in your binary. Someone can easily download your APK, run strings (or a similar tool) and then start sending GCM messages on behalf of your application.

If you want to do Android <--> Android messaging, you will actually need to do Android <--> Server <--> Android.



Related Topics



Leave a reply



Submit