Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am new to GCM and have a few questions regarding an app implementation. The app should be capable of upstream messaging. So -
Do I have to create a server (lets say in Google App engine) which will communicate with GCM. And then GCM will send the message to the app. Or I can do it just with CCS connection and my device can send message to app on another device without a server?
Is there a code example of writing server side code which I can use in App Engine? I badly need some tutorial/code implementation on CCS to understand the logic. I dont think android developer site is enough to understand things clearly.
Help appreciated!!
Hi Actually I am using http://parse.com to create server and push notification in android.
First of all you should always go to the source and read, as Google provides samples and everything.
About 1 and 2 then it depends if your going to use a third party provider or do everything yourself.
If your making everything yourself then YES you need a server and YES Google provides some code but I've never used it so I can't tell you how much work you have to put in it.
If you just want GCM capabilities but it doesn't have to be Googles, then there is plenty of alternatives out there: Parse.com and Urban Airship to name at least two.
Following link will help to code GCM but it is unidirectional(from third party server to cloud only)
http://avilyne.com/?p=267
Google GCM CSS provides upstream messaging that is from application(http://developer.android.com/google/gcm/client.html), you can send a message. This message will reach the Google server and they will send you the same message to your server, which you have to implement(https://developer.android.com/google/gcm/ccs.html).Do what you want with it.
If you have to send a message from your server to the client(application), you can send it via your css server or by making a http call to the google gcm http server. They will send the message to the client. You have to handle the received message and can show as a notification or use internally.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am completely new to the whole concept of push notifications. I have written a back-end server and I will send push notifications from it to the Android app, which is also written by me. But my question is:
Do I really need, or why would I need a Push notification service?
Thanks!
If you want to use FCM to send push notifications, at some point in time, someone has to make a request to Google's FCM service, because Google is the only one, who can send a message to a device via FCM. Same applies for APNS, at some point in time, someone has to make a request to Apple's APNS service
Depending on your requirements, you can do this yourself in your own code or you can use some 3rd party provider. Using a 3rd party provider MAY have benefits. For instance they may take care of token management, or provide a single request for sending to Android and iOS devices, and so on and so forth. But in the end of the day, also a 3rd party provider sends out requests to Google or Apple in your behalf.
You can use firebase cloud messaging service or using socket programming for this .
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
From my research MQTT brokers only save the most recent message but facebook uses MQTT in its messenger app. So are they using a custom broker to retain the messages?
https://www.facebook.com/notes/facebook-engineering/building-facebook-messenger/10150259350998920
My question is it possible for mqtt brokers to retain all messages sent so that I can create my own chat messaging mobile application? I know that paid services like HiveMQ offer this functionality but I am looking for a free alternative.
MQTT is a protocol for sending and receiving messages between a client and server. What either does with the messages beyond the basic requirements of the protocol will be implementation dependant.
You could use a application subscribed to a topic to store all messages in a database - it does not have to be a function of the broker component.
The usual MQTT broker works in a passive manner. It gets the message from publishers and forwards it to any available subscriber.
I think Facebook uses another process that receives the messages and then sends it to the clients again. The clients then can send another MQTT message when it receives the message.
However, MQTT has some QoS mechanism. It's possible to use it if there's a persistent connection to the client. Facebook may be making use of that too.
In case you need message persistence out of the box, it's not possible with MQTT though. You can use a technology such as Apache Kafka.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am working on a chatting app. In which one user sends message to another user. So there are two users(user1 and user2). when user1 sends a message to user2. On back-end I am sending the message to my web-server using post method, then user2 is always sending get request to server and receives the message in response. In this way my job is done but my question is that if there is any way to send a request from web-server to phone? and user2 can directly receive the message without sending request to the server all the time. Please help!
As #Linesh said above, could be one possible solution but rather unconventional using GCM for chatting purpose; instead you can make use of standard web sockets, which could be easily implemented in node.js, or PHP,Python, whatever server side programming you are supposed to be using. also based on websockets , have look at socket.io or you can make use of some third party chatting API's like quickblox, or pub-nub or even AWS as well.
Yes there is a way. You can use GCM to send the msg to phone.
The working would be like.
register both the devices with gcm and store the registration id to your server with the unique user id
when user1 sends some msg to server. then get the registration id of user2 and send the msg to gcm server.
user 2 will get the msg when he connects himself to some network.
this links will might help you
http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-1/
http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-2/
One big downside to using 100% GCM is that it can tie you to Android unless you take extra steps in your design to ensure that you can use other services too - with an improper implementation you could only do chat between Android phones but not, for example, Android to iOS, Windows Phone to Android, or Android to desktop client. This ends up being a significant downside since, based on statistics I saw recently, Android has an approximately 66% market share. While this sounds like a lot, this limitation would mean that you couldn't chat with 1/3 of people. iOS, Windows, and Amazon phones/tablets all use different push notification services. (One possible solution to this is to use AWS SNS Push, which will act as a "matchmaker" for different push notification services; this would improve the platform independence to some degree).
SignalR is another option. There are actually quite a few examples of chat apps out there that use it - it seems to be the canonical example actually.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Please suggest way to build watsapp like chat application.
In My Android application i have to put Chat Functionality
I already knows following ways.
Chat application by using GCM (Google Cloud Messaging).
Socket Programing
By using our webservice
Is there any other techniques for chatting app?
There are various methods to develop chat application.
1) Using HTTP connection (In this method each and everytime you want to send message, you have to call the webservice and for receive message, you continously need to call the webservice using Timer).
2) Using XMPP Server (XMPP server uses Socket programming, so once a connection will be establish, then it uses that connection each and everytime, you no need to create connection everytime, like HTTP).
3) Using GCM (Using Push Notification you can send and receive messages as well).
Things you need to build a chat app:
Server:
This is required to store all the user information like username, password and gcm registration id (will come to this later).
You can host it anywhere Amazon EC2, Google App Engine, etc
APIs for login, chat message sending, message list, delete message and many others.
Registration for GCM push notification:
Refer the link below:
https://www.digitalocean.com/community/tutorials/how-to-create-a-server-to-send-push-notifications-with-gcm-to-android-devices-using-python
Android:
Register to GCM and send the gcm registration id(as mentioned in point 1) to the server for updating.
Design user interface to send message, sending a message can be done either through REST API or by using socket connection.
You can explore XMPP and MQTT.
Server to Device communication and vice versa:
Now, on receiving message coming from the device, publish the message to the socket connection and as a fallback send push notification to the receiver device. There are 2 ways to do it:
i) Send the message payload along with the push notification
ii) Only send "sync" and on receiving the "sync" notification, receiver's android app can make a call to the server, fetch all the messages and show it to the user. Benefit of this approach is that the messages will never be lost. You will have to maintain the "sync" timing on the android app side.
Above was the normal way to build it if you want to learn but if you want to just get it done fast then you can integrate Applozic Mobile & Web Chat Libraries which will get you started with chat within half an hour. And the beauty is you wouldn't even need to develop or host any server.
Sample code to build chat in available in Github:
Android Chat SDK https://github.com/AppLozic/Applozic-Android-SDK
Web Chat Plugin https://github.com/AppLozic/Applozic-Web-Plugin
iOS Chat SDK https://github.com/AppLozic/Applozic-iOS-SDK
PS: I am the Cofounder #Applozic
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I've been trying to catch a push notification when the app is not running or in background mode.
I found this module https://github.com/jayeshIT/Google-Cloud-Messaging-Titanium
And only works when my app is running or in background mode. There is a way to catch push android without ACS ???? p.d. I tried creating a service with a interval but only works when the app is in background or running please help!
In order to implement push notifications for Android without using a third party service such as ACS or UrbanAirship, you must implement your own application server that stores and retrieves device registration ids that are created by Google-provided GCM Connection Servers.
Here is the Google documentation for implementing a GCM Server.
Basically, push notifications are sent from the sending device to the application server and then through Google's GCM Servers to the destination devices, where the devices' operating system receives the push notification an displays it appropriately.
It may be easier to implement push notifications initially using one of the free accounts on the third party services (ACS, UrbanAirship), and once the mobile functionality is developed and tested, implement the application server and refactor the mobile code as needed.
Hope this helps. If so, please up-vote (need the rep to use other features in SO :)
I would start with the Urban Airship module: https://marketplace.appcelerator.com/apps/4984
The module has support for iOS and GCM and its open source. Here are the direct links to the builds: android and ios
http://urbanairship.com/ They have a free tier. If nothing else this will get you started, and once you have this setup it will be easier to try and do it yourself.
There's plenty of documentation for setting up the API Key's for GCM, do you need me to track those down to?