can someone explain about how push notification or message in android working? Does it operate within a VPN? How can the server send data to the device if it's not in the same network? Is it possible to make your own push notification/message? Please enlightened me :)
Push Notification in Android means, Google Cloud Messaging. First we need to enable google cloud messaging service from google developer console. Then need to create browser key to give from server side.
Now, when user need push, we have to register the device id to the google cloud server and it saved it permanently.
Now when server fires push at that time server request google cloud to send message to registered device id, and using that device id, google sends message to that particular device. So basically, whole things are depends on Device id.
Related
I want to see all the logs of push notifications received on my android device. I'm sending the FCM token of my device to my backend server, and the push is sent using PHP code to my device.
Does firebase console provide any statistics/logs of all push received for the specific device?
Firebase doesn't keep the track of device-specific notifications.
Instead, what you can do is while sending notifications from the back-end, just keep the track of notifications sent to specific devices by storing this data on your database, and then you can fetch it on your android device.
you could do kinda of that. Using analytics labels (only with FCM API v1) you can see on the firebase console the stats about received messages. If you use a specific label only for your device, you will know how many notification have been received by that specific device.
https://firebase.google.com/docs/cloud-messaging/understand-delivery?platform=android
I was wondering how android push framework is able to distinguish data recieved via GCM and forward it to the appropriate android application for which it was intended ?
Can anyone let me know how it is done ?
You question : how android push framework is able to distinguish data recieved via GCM and forward it to the appropriate android application.
From your question it looks like you willing to know about data
workflow & Client Server architecture that exists in applications
which are using the GCM service.
As per google’s documentation “Google Cloud Messaging for Android (GCM) is a service that helps developers send data from servers to their Android applications on Android devices”. GCM is a service provided by Google for developer that helps developer to send data from server to any number of Android devices.
Simplified Application Specific Work-flow:
The push notification can be broadcasted either to the mass audience
or a select set of users. Mass audience is targeted when the
notification has to be sent about a marketing campaign. A subset of
users are targeted when a personalized information has to be sent.
The below steps explains how push notification works on android devices:
First android device sends sender id, application id to GCM server
for registration.
Upon successful registration, GCM server issues registration id to android device.
After receiving registration id, device will send registration id to our server.
Our server will store registration id in the database for further use.
Whenever push notification is needed, our server sends a message to GCM server along with device registration id (which is
stored earlier in the database).
GCM server will deliver that message to respected mobile device using device registration id.
This can also be understand using following figure
An Example Workflow:
So, from above images it easy to understand that whenever the android
application is first installed by the user, then it registers itself
to GCM server, and obtains unique GCM ID, then it's our Host servers
responsibility to keep this newly registered Registration ID of the
android user into Database, and then it will be used whenever server
side application willing to send the message to that particular
android user.
So, let us consider one case; suppose an Server wants to send Some data to Android User, which has already registered it's GCM ID 1234567 when it's first time installed, and as it's in the server's database the server application will fetch it from DB, and simply make a HTTP POST request to the GCM server in JSON format, which will have registered user's GCM ID along with the data to send , in same way the GCM Server has the record of all the Registered GCM/Android Clients, it directly forwards that message to the intended android user, and android app in user's phone will raise and Notification alert, to indicate an push notification has arrived.
Hope This answers an question!
GCM stands for Google Cloud Messaging.
Every push notification receive on any Android device is sent by the GCM only.
sender -> GCM -> Android Device
when sender sends an push notification then it goes to GCM. GCM receives that push and forward it to particular Android Device by its Unique device id.
GCM can't deliver Push without Unique Device ID.
while implementing push notification there are two important things, application key and server key ... these are unique Keys.. using these keys GCM identifies the application to whom push notification is related
I have created a small App that's able to receive Push Notifications from the FCM Console.
What i want to do now is to send a Push-Notifications to all Android Phones that got the app Installed using the API. And this is where i got completely lost.
Is there no way to send it to all Phones without collecting all the registration-ids?
Does this only work with the Console but not with the API?
thanx in advance
Sending a message to all the phones like what you do from the Firebase Web Console is only possible from the Web Console.
If you need this feature from the API you can submit a feature request:
https://firebase.google.com/support/contact/bugs-features/
Another possibility is to have all the client registering to a specific topic via FirebaseMessaging.getInstance().subscribeToTopic(topicName)
In this way you can send a message to the whole topic without collecting the registration-ids manually.
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
I'm trying to use GCM to establish communication between some users. They should send to each other their GPS location. Is it even possible? There is a subscribeToCloudMessage method but I don't know whether it will be useful or not.
Info: Server works fine (Google app-engine) with all the required keys.
It's possible for one app to send a message to another app via Google Cloud Messaging if the sending app knows the registration ID of the recipient app. Usually when a app register to Google Cloud Messaging, it sends it's Registration ID to a server, and that server sends GCM notifications. If you want the app to send the notifications directly, you must send each device (where the app is installed) the Registration IDs of other devices that it needs to send messages to.