Push notifications from server-android - android

I have an android application where a user can insert data into web sql server. I want all the users to receive push notifications when someone inserts a row into database. How to implement.

You can use Google Cloud Messaging (GCM)
Google Cloud Messaging (GCM) for Android is a service that allows you
to send data from your server to your users' Android-powered device,
and also to receive messages from devices on the same connection. The
GCM service handles all aspects of queueing of messages and delivery
to the target Android application running on the target device, and it
is completely free.
For more info on how to use it, refer to developer.android.com

Try this tutorial (or the official documentation) for specifics, but in overview you maintain a list of registration tokens for your users, and send the list of tokens for users you want to get a notification to Google and the send it out. Google will tell you afterward if any of those tokens are now invalid--those should be removed from your system at that point.
http://www.tutorialspoint.com/android/android_push_notification.htm

Related

Use FCM with another database

I am developping a mobile application that must implement push notifications. Documents are stored on a SQL database, and people should be able to edit these docs after downloading them offline, then the modifications should be saved in the SQL Database once the phone is online again. People should be able to receive notifications when the app is closed.
I heard that I need push notifications, and for android there is Firebase Cloud Messaging (FCM). But is it possible to use FCM with my SQL database ?
All tutorials in the docs only speak about connecting the app with Firebase
For your project you need a server with your API, SQL Database... and a push notification server that ask FCM services to notify your registered devices.
FCM works like that :
You add the FCM plugin in your Android/iOS app, then when you launch the application it will ask FCM for a unique token associated for your device and this app. You will store that unique token in your push notification server, I advise you to associate it with a user identifier or one thing that you will use to identify the device to notify.
When your first server (with the APIs and the Database) did some action and you want to notify a device :
The server will ask your push notification server to notify a list of devices that you will probably determine with the user identifier like I said earlier, then the push notification server will find the associated tokens and send all of the pre stored tokens to FCM with the notification content you want to send, you can also send parameters that will be used to do special actions in your mobile app.
Finally FCM will notify your devices :)
Hope it helps.

Android Notification to the End user

App is already published on playstore, can anyone explain the proper way or channel to create and send notification to the end user? Where i can also get the info regarding how much device has received the notification and how much user have clicked on the notification and checked it?
Implement GCM(Google Cloud Messaging) in your app and end users should install your updated app (with GCM)
“Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices”. Using this service you can send data to your application whenever new data is available instead of making requests to server in timely fashion. Integrating GCM in your android application enhances user experience and saves lot of battery power.
--https://developers.google.com/cloud-messaging/
GCM tutorial available in this link.
Happy coding :)

Android application that sends data to all application holders

I have this application that notifies its registered users on updates about something...but the things is that I don't know how to send that data as a notification to all of the applications users
To send data as notifications to users you could use Google Cloud Messaging (GCM).
With GCM users can automatically register with you when they first run the application. You save their unique id in a database somewhere and then you can use these ID's to send messages (data) to the Google servers who will then push this data to the Android devices.
To read more about GCM and how to implement it check out the Android Developers site: http://developer.android.com/guide/google/gcm/index.html

how to create push notification in android?

I am developing android application that would receive data from server any time.i have searched in google to get some information.
1)android cloud to device messaging(C2DM).
2)persistent TCP/IP connection.
how to implement C2DM function and other one how to register C2DM?.please explain detail and send me sample application
C2DM is deprecated and you can use GCM for your requirement
Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices. This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly). The GCM service handles all aspects of queueing of messages and delivery to the target Android application running on the target device
This document describes how to write an Android application and the server-side logic, using the helper libraries (client and server) provided by GCM.
Check these links,
http://developer.android.com/guide/google/gcm/gs.html
http://developer.android.com/guide/google/gcm/demo.html
http://www.basic4ppc.com/forum/basic4android-getting-started-tutorials/19226-android-push-notification-gcm-framework-tutorial.html
http://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/
for client side app you can find the code here
https://github.com/marknutter/GCM-Cordova
c2dm is deprecated.
https://developers.google.com/android/c2dm
Maybe you'd better start with GCM
best regards

Instant Messaging on Android with Google Cloud Messaging

I was just looking at the new Google Cloud Messaging (GCM) and I was wondering if it is possible to use GCM for Instant Messaging on your Android application?
I saw you can send data, like a message, from a server, but is it also possible to send from one device to another one?
And how would this work?
Some example code would be really helpful..
Tnx!
The official docs on Google Cloud Messaging for Android does mention that GCM can be used to develop an instant messaging app.
...or it could be a message containing up to 4kb of payload data (so
apps like instant messaging can consume the message directly).
So we went ahead and created an instant messaging app using GCM. The server-side is powered by Google App Engine. You can read the complete tutorial here. Create an Instant Messaging app using Google Cloud Messaging (GCM)
So it is possible to use GCM for Instant Messaging on Android, to answer your question. However, reliability of GCM compared to XMPP for IM is another topic.
Just my two cents:
I think you should not use GCM for delivering IM. You should have a dedicated server where your Android IM apps will connect to, using a persistent socket connection. Your server will know who is online or not and therefore can present an 'online list' to all the apps.
GCM can come into play, while users are offline or not running your app. A GCM message can be sent to them to indicate 'XXXX wants to chat'. They can then launch your app and automatically connects to a chat session.
Google has said that the delivery of GCM messages are not guaranteed. This reason alone is not a good idea to rely on them for Instant Messaging.
Try pub nub - it is pretty easy to implement - send Im from one mobile to another - simply fire up the web page (see link) in the browser , and chat between pc, mobile - and works - with 'no server'. Code is for javascript but they also have java. Chat app using jquerymobile web app framework
You might want to check out how a server sends a message to the GCM Service. It is possible to use php on Server side so it should be possible to adapt that to a POST request directly out of your application. However, to communicate you need the registered ids of the devices you want to send data to. Means you will need something to store and get them. Best solution would be your own (web) server which stores all ids and handles the Message sending.

Categories

Resources