I am an android developer ....have made a few apps...but for the first time had a chance to implement push notifications for one of my apps... After looking for a number of solutions including Amazon SNS, Pushbots, Pushy, Parse etc.I was wondering on why there are a lot of popular third party services...
If they implement the same GCM. GCM also provides a dashboard with tracking and topic based notifications.
Is there any disadvantage if I am using GCM directly. Also a big question... most of the push services only offer sending notification to apps... what if I need to trigger notification from my android app. Does GCM supports this. What are the best solutions for implementing this.
Related
Currently i am using onesignal.com push notifications. Is there any better service or better way to send push notifications in Android with more features?
You can use both GCM(Google Cloud Messaging) and FCM (Firebase Cloud Messaging).
Some features of GCM are deprecated so Google is suggesting to use FCM.
FCM has a killing feature of sending notification to all users who have installed your app all or to those users who have subscribed to a particular topic(You can even check for topics i.e. Weather report for INDIA(who stays there),AUSTRALIA(who stays there).
You can implement FCM in your app very easily.
With FCM you can either use a Third Party Server or can send notification using their own cloud service.
Just visit and register your app with a coolest feature provided by Google-FireBase Cloud Messaging.
You can even check some videos on Youtube-Google Developer Videos
I use it with a lot of very nice handy feature here
I'm using Firebase (https://firebase.google.com/). It's easy to learn and has good documentations.
You can use FCM (Firebase Cloud Messaging) to implement push notification. for better understanding go through this article
I am building an Android app with a server at back end. What I want to do is, whenever anything new is updated in server the app should trigger a notification into the users phone showing the newly added content.
EDITED TO ADD: This is even more important as of Android M and beyond. As part of a comprehensive effort to improve battery life, the OS actively restricts many of the techniques that apps have used in the past for sync and notifications. Use built-in methods like JobScheduler and GCM in order to avoid issues.
The core notification mechanism in Android is Google Cloud Messaging (GCM), documented here. It's built in to the platform at a low level and directly supported by mobile networks, so it's usually the most efficient choice. It doesn't have a guaranteed latency, so it may not be appropriate for very time-sensitive messages, but it's generally quite fast--at least as fast as sending SMS, for instance.
There are a number of different commercial products as well as FOSS libraries that wrap GCM in various ways, for instance to provide support for very old (pre-Froyo) devices or devices without Google enabled, or to provide a single cross-platform solution between various competing mobile platforms. Firebase, Parse, and Urban Airship are some that I'm aware of.
To use GCM, you need to get an API key from Google. You use this API key to authenticate requests to the GCM server. Once you have a key, sending a notification is as easy as sending a POST request to the GCM server. GCM also supports XMPP, but I haven't used it.
On the client side, your app needs to call the GCM API to register for messages. You provide the project name that you used to create the API key, so that GCM knows which server messages should go to your client app. Once your app has registered, incoming messages will be sent to it as intents, which you can receive by implementing a BroadcastReceiver.
There's a tutorial on the Android developer site that walks you through the GCM process.
I want to send a notification from some server to android device. The most obvious(and power-hungry) way is to keep searching some database for any new messages using a service/broadcast receiver.
I am sure there are other ways to get this job done. I took a look at GCM(google cloud messaging) , and it seems that google always keeps some TCP/IP connection active. This essentially means that using GCM will use less power.
However, I have a few questions regarding GCM.
Does a user NEED to have google services, and a registered play id ?
If a user side-loads an apk, will he still be able to receive notifications ?
I would like to know if there are alternatives to GCM
What about devices running forked android versions, like nokia X , kindle etc? How are push notifications sent to those devices ?
Does a user NEED to have google services, and a registered play id ?
Yes, it is necessary to use Google Play Services in your development. However users do not need to have a Google account or the Google Play Services Installed.
If a user side-loads an apk, will he still be able to receive notifications ?
Yes.
The steps that must be followed to send a notification to a device are:
Developer creates application in Google Developer Console
User installs application
Application gets a NotificationID and sends it to your database
You store the NotificationID at your servers with any other information related (your username, device info, etc.)
Whenever you want to send a Notification you connect to GCM sending one or more NotificationID and the notification content.
The users related to the NotificationID will receive in your Application the notification content.
Do any action you need.
Have a look here.
IMHO there is not any real alternative to GCM in Android (based on efficiency and simplicity). You may look for 3rd party services that will help you in the implementation and add value (marketing, business intelligence). As an example of this take a look to UrbanShip.
If you want to implement your own solution you should have a look to WebSockets. This will mantain an active communication between your server and the device. Those sockets are thought for real time communication between your server and the mobile.
Two issues:
How is the application affecting the battery depends on your implementation and the application use-case (how frecuent are you sending information, how long is the connection stablished).
I am not aware of any native implementation of this in Android but there are a few Libraries coming from open source projects. Google it.
I have an app that currently uses C2DM for push notifications. I would like to inquire if I update the app to GCM and if some users do not upgrade their app, will Google allow me to use both the C2DM and GCM for the two versions of my app?
Or will the users on my previous app never receive a PUSH notification altough I still have the push logic implemented for C2DM?
I've completely replaced C2DM with GCM in the app, and left support for both protocols in the server side. Works like a charm; details are here.
They will still receive them as long as you don't remove any authorisation keys, ids etc. as GCM uses the Project ID while C2DM uses the registered e-mail address.
More on it here: C2DM to GCM Migration
Once the C2DM service was deprecated recently I advice you to migrate your pushes system to GCM service.
The best way to deal with it is doing the thing like Google says. Take a look at this topic in the official GCM's documentation.
While not the original question, an interesting one would be: Can one app simultaneously use C2DM and GCM.
C2DM uses the Sender-Account while GCM uses the Project-ID to register. The only thing they both might share is the App-package name (and obviously the google account of the device, but that shouldn't matter as there are multiple apps which can use gcm/c2dm in parallel anyway).
In my experience registering C2DM and GCM in the same app can cause some serious problems.
Reason to have both in one app might be that you want to use GCM in the app, but can't everywhere because a legacy backend might not be able to switch to GCM yet. Probably a rather rare scenario - but currently happening for our app.
I am looking for an optimal solution to implement chat server for android clients on GAE.
At the moment I use C2DM to notify particular users about new messages and pull data from server after such notification. But sometimes C2DM servers delay notification message and it stops to be realtime.
I also had a look on XMPP and it seems that it is mandatory to have an external XMPP server like google talk, so it is not what I am looking for too.
Is there another way to implement chat on GAE? Any advices are warmly appriceted!
The Reason why you are experiencing Delay with C2DM is because it is not real time. Google actually says this: It isnt the most reliable way. It suggest having a third party server such as XMPP
You can implement chat on App Engine using the Channel API, but the only supported clients for that are browsers. If you're prepared to make your Android app browser-based, that would be a solution - otherwise, you will have to look into third-party services, like Urban Airship.