I want to implement Google Cloud Messaging (GCM) for the sole and singular purpose of sending messages to Topics. I am building an android app. I do have an app-engine endpoint server, fyi. I am wondering: what parts of the Set up a Client App on Android process do I not need to implement?
Here is what I already included
google-services.json
compile "com.google.android.gms:play-services:8.1.0"
the manifest edit portion (copy and pasted block pretty much)
But do I need to, for instance, obtain a InstanceID? What else do I need or not need? Ideally if someone has an example that exclusively uses "Topic Messaging" that would be great. But short of that, I can carry on with some pointers.
Do I need GcmListenerService, InstanceIDListenerService, and RegistrationIntentService?
Sending topic messages with GCM is very similar to sending regular messages with GCM. The only differences are that the client must subscribe to the topic, and the sender must send to the topic.
To you questions about do you need GcmListenerService, InstanceIdListenerService and RegistrationIntentService... Yes.
Please have a look at this quickstart which demonstrates GCM using topic and non-topic messages.
Also note that you should not be using:
com.google.android.gms:play-services:8.1.0
please use:
com.google.android.gms:play-services-gcm:8.1.0
Related
I have written a test app where users can publish some data (location, photos, tags etc.) to their "feed" (i.e. write some data to an online database which is currently Firebase). If other users are "following" this user (or a relevant tag), how do I send notifications to the followers that new data is available?
I have looked at Google Cloud Messaging and the replacement Firebase Cloud Messaging, but I find their documentation too technical for me (seems aimed towards I.T. professionals). I can program but don't really understand "servers", "protocols" etc. It seems from GCM/FCM docs I need a "server" before I can use their services. This server will
Recognise when a database event happens.
Run some logic to ascertain whether notifications need to be sent out (and to whom)
Inform GCM or FCM to do so.
Is this correct? If so I don't know how to get a server, write one, plug one in or whatever it is I'm supposed to do with one. Any advise or simple tutorials that anyone can give a neophyte developer is greatly appreciated!
Thanks,
Riz
It seems you're trying to implement GCM Topic Messaging where your app server sends messages to mulitple devices that are subscribed to a particular "topic". Though this particular feature doesn't seem to be that feasible, it is doable.
Before your followers can get notified, they must first be subscribed to a topic.
Here's how to subscirbe in Android:
private void subscribeTopics(String token) throws IOException {
GcmPubSub pubSub = GcmPubSub.getInstance(this);
for (String topic : TOPICS) {
pubSub.subscribe(token, "/topics/" + topic, null);
}
}
Try this actual demos to get a grip on this:
GCM Playground - A reference implementation of a GCM Application Server in the form of a playground that developers can use to test the Google Cloud Messaging Service.
Since Google now encourages users to use FCM, try the FCM Android Quickstart. You can also read through this SO post for additional insight.
I'm writing an application that need to read notifications from a "MySql" database... I want send a message from my server to app that when a notification send to a user, it sync notifications with my db...
I read about it on net, and I found something about Google Cloud Message (GCM) that has a service called "Send-to-Sync Message" but i can't find a good tutorial... I don't know how to use this thing in my app.
Could you please help me or give me a good tutorial?
Does it need a VPS?
There is GCM documentation.There also you can find tutorial about GCM server implementation. Also about "Send-to-Sync Message" pattern you can read this advanced topic. And you can use for debug purposes my test push server. Hope, this help you.
I am working on an android project where client needed to send just a single sms/text (yes, sms only) to GCM like server and GCM service will handle delivery of message to thousand of target Android devices. I am in doubt whether it is possible or not. I searched a lot but not found a reliable answer anywhere.
It is definitely possible to accomplish this with GCM. This is exactly what GCM was made for. Follow the instructions from Google and you'll be good to go.
https://developer.android.com/google/gcm/index.html
Alternatively, if you only want to send an sms, why don't you just send an sms...
If I want to create an instant messaging application using android, is it a good and efficient to use the Google Cloud Messaging API ?
There are a lot of mentions in GCM documentation and tutorial saying that is no guarantee of order and success receive of messages. Like here:
Note that since there is no guarantee of the order in which messages
get sent, the "last" message may not actually be the last message sent
by the application server.
I suggest you use this as a call to update user chat e.g. when your app get a GCM you request your server-side to get the new messages but not transfer messages by GCM itself also because you have some dayly limits as well.
See more here: http://developer.android.com/google/gcm/index.html
I found the mention above here: http://developer.android.com/google/gcm/server.html. At description of collapse_key here: http://developer.android.com/google/gcm/server.html#params
Yes, it works for Google and you won't have to maintain servers. If your message is short, in can be included in the GCM message. Otherwise the GCM could be a payload to notify your app to check for a new message.
I've been following this guide
and still dont get it (Im quite new to the whole android-stuff, Im sorry).
"1. Create a servlet (or other server-side mechanism) that can be used by the Android application to send the registration ID received by GCM . The application might also need to send other information—such as the user's email address or username—so that the server can associate the registration ID with the user owning the device.
2. Similarly, create a servlet used to unregister registration IDs."
I dont think this guide is very thorough overall but right here I ran into some trouble. Is there any kind code-cracker out there who can help me?
How do I make a "servlet" for GCM?
Thank you in advance!PS. Im using eclipse
You should probably take a look at the GCM Demo Application page, specifically the Setting Up the Server section which shows two methods for setting up a GCM server. I have seen a few other GCM developers using Google App Engine for their GCM servers as detailed in point two of the link.
There are also commercial solutions out there such as AirBop (which I happened to help create), Urban Airship, and a few others.