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
Android Listview with Header and Footer Buttons
What Is More Efficient? Static, Data Passing, Shared Preferences, Database...
How to Solve Render Problem Path.Op() Not Supported
Download Images Using Android Webview
Obtain Root Access via Su on the Android Emulator
How to Stack Firebase Cloud Messaging Notifications When the Application Is Not Running
Ionic2 Background Image Is Resized When Keyboard Is Open
Resources and Layout Direction Rendered Incorrectly Only on Android 8.0 and Above
Firestorepagingadapter Not Receiving Realtime Updates
Open Google Maps Through Intent for Specific Location in Android
CSS Reference to Phone's Emoji Font
What Happens to Older Clients When You Migrate an App Server from Gcm to Fcm
Android Studio on a Hardware That Does Not Support Virtualization Technology
Black Screen Before Splash Screen Appear in Android
Trying to Fix Networkonmainthreadexception But Gives Toast Error