My app seems to be properly implemented on Android; this gets the token for a specific project number as well as this subscribes the client to three different topics. The token wasn't sent to the server because it specified here that for topics it is not needed, in server side, to have it.
The app server can send out the messages to the GCM server and gets the ID for the message. However, the client does not get any message. In the logging there is no information about anything. I already posted a question with some details about my problem. Unfortunately, I did not receive any reply to my question, so I wonder if someone has implemented a client of GCM based on topics successfully and could give me a help.
Related
I'm new to push notifications and here's what I understood so far -
Client app will need to register with Google Cloud Connection Server (GCCS).
GCCS will return a registration ID back to the client.
Client will send the device id and registration ID to the app server.
App server will store device & registration in its database. This database could get huge depending on the number users.
The app server in my case comprises of a single HTML page, and a node.js script. Admin will get to the page, types in a message and hits Send.
The app server will make a POST call to GCCS with the Sender ID, API Token, array of registration ID's etc.
Message is received by the devices.
There is also this thing called as Topics that the client apps can subscribe to. Using Topics, you do not have to send registration ID's of all devices. All devices "subscribed" to this Topic will get the message. This is very useful if you have millions of users (depending on the popularity of the app) and you don't have to split the registration ID's into chunks of 1000s to send the message.
My questions are -
If we're using Topics, do we need to persist the Registration ID, Device ID to a database on the App server? It seems redundant.
Are there any ready-to-use/commercial GCM servers that can send Topic messages?
Is it easy enough to build on your own (since its a simple POST call)? If I'm going to use JavaScript, wouldn't I run into CORS issue?
Thanks for the help!
If we're using Topics, do we need to persist the Registration ID, Device ID to a database on the App server? It seems redundant.
Are you referring to C2DM implementations? Those are deprecated as shown on the GCM documentation. In relation to topics, they may not be necessary but are necessary to other message calls.
Based on the documentation, to needs to be set as topic/[yourTopic] with the necessary payload
https://gcm-http.googleapis.com/gcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to": "/topics/foo-bar",
"data": {
"message": "This is a GCM Topic Message!",
}
}
Are there any ready-to-use/commercial GCM servers that can send Topic messages?
I can't find any sources about this, so I'm guessing we're left to implement it on our own application server. Google provided us with a sandbox project for us to play with.
Is it easy enough to build on your own (since its a simple POST call)? If I'm going to use JavaScript, wouldn't I run into CORS issue?
If you're talking about setting up the Client App (specifically Android), there's a setup guide on the documentation. But if its more on the application server, I can't comment on it really. XMPP libraries can be used to handle XMPP Connection Servers
I'm totally new to hybrid world so I have to ask first.
Can I send notifications through GCM without a server?
I mean, I'm building a SPA with AngularJS and Firebase, but my customer asked me to make a dashboard for Android, so every time an user makes an order, they (both dashboard administrators) receive a PUSH notification on their phone: "A new order has been created", and when they "tap", the application opens.
I've been reading something about /topic/ endpoint to notify both of them, but I think I still need a server to do it. Do I?
It would be great if I simply post a http query using something like AngularJS' $http service to tell GCM to send a notification for that topic/usergroup.
Is that possible? If so, any idea about how?
Thank you very much in advance!
Sending a downstream GCM message can be done "without a server". One option is to send an HTTP request to GCM containing the required fields. Topic Messaging is available with GCM which does make it easier to send downstream messages without a server. Your client apps can subscribe for messages from /topic/usergroup and then you can send an HTTP request with /topic/usergroup as your "to" value, and subscribed clients will get it.
Note that you will need to set up a Google Developer Console project to get the required API key.
Check here for more information on the structure of GCM HTTP downstream messages.
I am trying to understand the concept of gcm upstream messaging.
Well what I came to know till now after browsing for hours is this :
1)My client app sends upstream message to gcm server.2)GCM server then sends it to my 3rd party app server.3rd party app server responds to it my sending ACK to GCM server.3)Then GCM server echoes the message to the recipient device(recipient Id is included in the upstream message sent from the app).
I don't if its what actually happens.
Now that I am sure that in some step GCM server sends mesaage to my server, how actually GCM server
sends message to my app server. How does it come to know about my app server as there is nowhere where we put my server's address
I have searched the whole Internet but couldn't find anything about this.I have gone through several SO questions but I couldnot find my answer.
I want to know the entire series of steps what happens during this entire process. I am very confused.I want to know the entire concept and what's going on behind all this.
Any detailed explanation with all steps will be appreciated.
To inform I have read the Google docs.
You have much of the flow correct but I think another read of the Docs will clear things up.
Your application server must act as an XMPP client, and connect to CCS (GCM's XMPP server). Your server connecting to CCS is how GCM knows the "address" of your server.
Cleaning up the flow you suggested:
Your app server connects to GCM's CCS.
Your client app (android app) gets a registration token.
Your client app (android app) sends that token to your app server.
Your client app send upstream message to GCM.
GCM fwds that message to your application server.
Your application server send Ack to CCS.
Your application server handles the received message.
Note the above flow is a possible one, there are many others, also downstream messages are not part of the flow. Again refer to the docs for more details.
I'm trying to follow the official guide for setting up a GCM client.
The Situation
After having set up everything just like in the guide,
I am able to send a message over to the GCM, using:
gcm.send
Then, exactly as should happen, the broadcaster calls to my intent's OnReceived procedure.
So far so good.
The Problem
Upon receiving the actual data, meaning - the intent's extras as a Bundle object, a problem occurs.
The extras' content (toString) contains an error:
Bundle[{error=TooManyMessages,
message_type=send_error,
google.message_id=1,
android.support.content.wakelockid=1}
The Meaning
Now, I've done my research, but came up with no practical answers. Only an explanation as to what is happening. Here is the problem, and its explanation:
This means that too many messages were stored in the GCM server for a single device without being delivered (which might happen if your device was offline while many messages were sent by your server).
Once the number of such messages reaches the limit, which is 100 if you don't use a collapse key, they are deleted from the GCM server, and you get that error message, which informes you your device should sync with your server in order to get the lost messages.
The Question
So, according to the answer, I am to sync my device with the server. How, exactly?
Also note, I have not created a GCM server. I'm only using the official GCM client implementation.
Thanks in advance to those who help!
-P
It's unclear what you are trying to send and to whom. The gcm.send method sends a message from your application to your server. For the message to big delivered, you must implement a server that connects to the GCM Cloud Connection Server. Since you don't have a server, GCM can't send the message to your server, and stores the message. Once too many messages are stored, you get the TooManyMessages error.
You must implement a server in order to use GCM. If you only want to send messages from the server to your app, you can use the simpler GCM HTTP API. If you need to send messages from your app to your server, you should use the GCM CCS API.
The answer you are referring to describes a different situation in which you can get TooManyMessages error (when the server sends many messages to the same device, but GCM can't deliver those messages), but it's not relevant to your situation.
**Question (i)**
I have registered my android app in my mobile (Samsung Galaxy Pop) i am recieved a
registrataion_id
APA91bG9NI4U2jr4sUn1HLy5nHMFe1e0JOTgOoZv1Px**********************************
when i sent this registration_id to server side code which is refrenced from here
here i used function SendNotification having 2 parameters
My Registration_ID
My Message Which i want to show on notufication
http://www.codeproject.com/Tips/434338/Android-GCM-Push-Notification
I hit the GCM- Server and the result I got is
id=0:1368258967353783%978fee9266d6cf16
I did not understand what does this response means ? is it good ? bad ?
Question (ii)
if mobile device gets registration id from gcm server is it registered or still waiting for server side to send the Registration ID to GCM Server
Please help !! , Thanks in advance
Answer to(i)
The data you are getting is on plain text format and the data is refering to the message id. In this case the message was correctly sended.
To understand how it works visit this page GCM Architectural Overview
Answer to (ii)
The way GCM works it's
Your device request a registretion to GCM services.
Device is registered correctly by receiving the regId.
You send that regId to your server to receive push notifications.
Server saves the data
Servers wants to send a message to that device, sends a mesage using GCM services.
The device, if it is online, receives it and knows wich app haves to start.
The app receives the message.
On the same website you have further explanation, by the way start reading from getting started section.