Android Cloud to Device Messaging without google account - android

Is it true that if a user does not have Cloud to Device Messaging (C2DM) in his account the C2DM will not work?
If so, how can I do push notifications without a Google account?

The different techniques to send push notifications can be listed as follows
Android Cloud to Device Messaging (C2DM) on OS2.2+
Other techniques for pre OS2.2 Devices.
Cloud to Device Messaging (C2DM) OS2.2+: The standard push notification method used in the android platform is called Android Cloud to Device Messaging (C2DM). The service provides a simple, lightweight mechanism that a server can use to tell an app to contact the server directly, to fetch updated data.
C2DM allows to send lightweight messages to android apps. The messaging service is not designed for sending a lot of user content via the messages. Rather, it should be used to tell the apps that there is new alert on the server, so that the application can fetch it.
C2DM limitations:
The message size limit is 1024 bytes.
Google limits the number of messages a sender sends in aggregate, and the number of messages a sender sends to a specific device
C2DM makes no guarantees about delivery or the order of messages
C2DM requires users to set up their Google account on their mobile devices.
C2DM requires devices running Android 2.2 or higher that also have the Market application installed
Server should be
Able to use HTTPS to communicate with C2DM Server.
Able to communicate with our client.
Able to fire off HTTP requests to the C2DM server.
Able to handle requests and queue data as needed. For example, it should be able to perform exponential back off.
Able to store the ClientLogin Auth token and client registration IDs. The ClientLogin Auth token is included in the header of POST requests that send messages. For more discussion of this topic, see ClientLogin for Installed Applications. The server should store the token and have a policy to refresh it periodically.
Other techniques for pre OS2.2 Devices:
Poll rather than push
SMS
Persistent TCP/IP
Third-party offerings
Poll rather than push: Android app can periodically poll the server for new messages from a background local service. The more often you poll the closer you get to the real-time push.
Adv: Easy to implement.
Disadv: Not real-time.Will kill the battery.
SMS: Android apps can intercept text messages in the android phone.So if a server can send an sms when there is a notification, the android app can receive the sms and then check for new data at server.
Adv: easy to implement. Fully real-time updates.
Disadv: Can be costly to do.
Ericsson labs provide a hosted service which allows upto 2000Sms's to be sent.
Persistent TCP/IP: The android app initiates a long-lived mostly idle TCP/IP connection with the server and maintains it by occasionally sending keepalive messages. Whenever there is something new on the server, it sends a messages to the phone over the TCP connection.
Adv: Fully real-time updates.
Disadv: Hard to implement a reliable service on both the phone and the server side. The Android OS is known to be able to kill services when it’s running low on memory, so our notifications service can easily disappear. What happens when our phone goes to sleep? Imagine if all the apps use the same technique . there will be plenty of open connetions which will drain the battery.
Third-party offerings
Urban Airship Push : The big disadvantage is that it requires the user install the AirMail app onto their device.
The deacon project
xtify
pushdroid.org

Related

How Firebase Push Notification is send to device

I am trying to figure out how Firebase connect to specific devices and send message to it. I now how to use Firebase and send notification to registed devices from my backend server but i don't know how is it working internally. Is firebase severs using persisted connection between device and server? What kind of tehnology is it using?
For now i am mostly interested in Android devices and how firebase wake up device even with background tasks restrictions.
FCM is able to wake a device because the message is actually received by software components that come with Play services, which operates with elevated privileges. Play services can choose to wake the device and deliver the message to the target app.
The FCM software in Play services keeps a persistent socket connection open to its backend under normal circumstances. If it gets connection is dropped, it has logic to reestablish the connection without taxing the battery too much.
I tried to explain how GCM works in my answer here. The internal working principle of Firebase is similar in my opinion.
When you are installing an application which has the Firebase SDK set up in it, it gets a push registration ID from Google server. Usually, you save the push registration ID in your server as well. Hence, when there is a situation for sending a push notification, your server uses this push registration ID to generate a request to the Firebase server for sending a push notification to your device.
Now let us think of the receiver part as well (i.e. your device). In my opinion, in newer versions of Android allows a JobScheduler to check repeatedly for push messages from the Firebase server and if there is one, the device notifies the corresponding application and the application then generates the push notification.
Hope that helps!

Is a server required for Firebase Cloud Messaging?

I am currently developing an Android app and I would like to include Firebase Cloud Messaging.
I was planning to have a Raspberry Pi checking a website every 5 Minutes or so and sending push notifications when something changed.
In the official documentation they say that I need an 'app-server' in order to send messages via Firebase.
Does that mean I need to have my Raspi up and running as a server 24/7 and need a static IP / Domain for it?
Or is it enough to have my Raspi send the message via the Api (https://fcm.googleapis.com/fcm/send) as I only need downstream messages?
Any help and explanation would be highly appreciated as I can't find a definite answer in any thread or documentation.
You don't as such need an app-server for just one device. If you have some sort of internet connectivity on your Raspberry Pi device, all you need to do is make a request to the firebase API.
Firebase (Google servers) will handle the rest by pushing notifications to all the registered devices.
Sending downstream messages (messages to devices) requires that you specify the FCM server key. This key allows sending FCM messages on your behalf, so should only be used on environments you trust.
Typically this means a server that you control. But the recently launched Cloud Functions for Firebase can also serve as such a trusted environment. After all: only developers who have access to your Firebase project can access your Cloud Functions code, and those developers can already send messages using the Notification panel in the Firebase console.
Any device you control in your own environment is also fine as a trusted environment. It doesn't have to have a fixed IP address, since the FCM server typically receives its instructions through XMPP or (more commonly these days) through the Firebase Database. Both of these approaches initiate the connections from the trusted device to Google's servers, so can run without accepting incoming connections.
You don't need any server to implement FCM.

Android client to client messaging without my own server for GCM

I am doing a prototype that involves messaging between clients.
What I want to do - from MyApp on device1, able to send message to MyApp on device2. Device2 should receive this and show a notification.
I don't have my own application server to push notifications from GCM to GCM clients.Is this possible ? How to do it ?
What I investigated - PubNub, which has a trial license that seems to answer my need to send messages on a channel without needing a server.
This discussion at SO didn't help much.
sending client to client messages without server interaction
Can anyone suggest better ways ?
You basically have to use a server in one way or another. I think Firebase would be perfect for your purposes. It has an Android plugin you can use that will basically alert your app when something changes in the database. Here is the documentation for that feature. Take a look at this example for implementation. Before you can use the plugin, you need to create an account and whatnot (basic one is free). Here are the instructions.
PubNub Realtime Messaging and Push Notifications
(server not required)
With PubNub, you do not need your own server to do the realtime messaging or the mobile push notifications. You likely have your own server for your database (MySQL or similar, traditional RDBMS, a No SQL DB like MongoDB, or a realtime DB sync, like Firebase) to authenticate users and such.
For realtime DB or non-DB type change notifications and signaling (any type of realtime messaging), PubNub makes is super simple to receive messages in realtime with a mobile push notification fallback in one publish action. So the GCM message will be sent along with the realtime message. If the app is actively running, you get it in realtime (< 1/4 on average - typically faster) and the GCM message will be received if the app is not active (background or not started at all).
And PubNub's free plan is not a trial (anymore). It is free (including all add-ons) for as long as you stay within the free plan limits.
See the PubNub Android docs for more details and contact PubNub support if you have any further questions with getting started or getting answers to any questions you have as you progress with your app implementation.
Another possibility is to use the SMS.
Android Send and Recieve Messages
"Send Binary (Data) SMS
We can send binary messages (as opposed to text based messages that we covered earlier) to specific application ports using sendDataMessage(). According to this Stack Exchange thread data sms is one which is sent over 2G/3G as well as GSM. I’ve tested it with mobile data turned off and it works fine charging me the same amount, so not very sure on whether it uses 2G/3G or not, but generally the term data is used in telephony when it’s related to network (tcp/ip). Anyway, SMS’s are generally sent to a specific port on the device (which is probably port 0 [zero]). But using sendDataMessage() we can send SMS’s to some other random port on which our app can listen for incoming SMSs and do something with that. In this case the default messaging app will not store the SMSs in their inbox for both the sender as well as the receiver.
"

Google Cloud Messaging for Android works from server to client, but also viceversa(from client to server)?

stackoverflow fellows,
Since I am very new in Cloud Computing matters, I would like to ask you a question: Google Cloud Messaging for Android works from server to client, but also viceversa(from client to server)?
I am asking you this, because I am currently developing an Android application. The structure, in general lines, it's something like: I would like to use my laptop as a server - and perform all the computations here. Then, from my server (laptop), to send everything in the cloud, and from the cloud, directly to my Android running device. I want to perform the computing and database storage on my local server (because, since I am a student, I won't have enough money to actually pay for a server from google (let's say), so I am focusing on what's free and suitable to my needs) and just communicate with my Android device using Google Cloud Messaging for Android. (I want my application to be independent from the hardware of my mobile device, and also, I want to write the program that will perform the computations on my server in Java).
I know that I can send messages from the server to my device(through cloud), but the question is: can I also send messages from my device to the server ? I am asking this, because the computations will be made after I submit something from my device (basically, my Android application will be an interface, from where I can send the data to my server (through cloud) and then receive (also through cloud) the results of the computation on my device)
According to what I've been currently reading (http://developer.android.com/google/gcm/index.html) it seems that I can only send messages from the server to my device, but I decided to ask, since, so far, was the only free messaging framework(using cloud) I have found.
Thank you.
You can use GCM Cloud Connection Server to send messages from device to server.
Paragraph from this page:
http://developer.android.com/google/gcm/ccs.html
The GCM Cloud Connection Server (CCS) allows third party servers to communicate with Android devices by establishing a persistent TCP connection with Google servers using the XMPP protocol. This communication is asynchronous and bidirectional.
Google Cloud Messaging for Android works from server to client, but
also viceversa(from client to server)?
Sorry but GCM(Google Cloud Messaging) is only made up for sending Push Notification from server to device. Not for Viceversa.
I know that I can send messages from the server to my device(through
cloud), but the question is: can I also send messages from my device
to the server ?
For sending the message or anything(For Example: Photo,files..) to Server why Don't you Use Web services for it. I think it will Be suitable according to your Needs.
It is correct what KashifB wrote:
You can use GCM Cloud Connection Server to send messages from device
to server.
But keep in mind that Messages with Payload have a size limit of 4kb per message.

Any library to exchange messages (pub/sub) through network on android?

I'm building a Server/Client app on android. There're many clients will connect to server using wifi, server will broadcast update messages to clients, and clients will send query message to server.
I implemented it with threads and sockets, it just looks too complex to me. Is there any library I can use so I don't need to care about stuff at low level (e.g. check connection alive and reconnect if necessary)?
Update: The deploy environment has only local network (WIFI), no access to Internet.
Have you looked at Google Cloud Messaging?
Google Cloud Messaging for Android (GCM) is a service that allows you to send data from your server to your users' Android-powered device. This could be a lightweight message telling your app 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. GCM is completely free no matter how big your messaging needs are, and there are no quotas.

Categories

Resources