Is it possible to create a Push Notification in Android? What I exactly want is whenever I have something to say to the users of my Application, I want some Alert Dialog to pop out "only" if I have something to say like "The new update is now available in the market, please update your application". Can someone guide me with this?
-
[**Here**](http://stackoverflow.com/questions/1378671/push-notifications-in-android-platform/20279735#20279735) I have posted solution, For Push Notification Implementation,May help you. – swiftBoy Nov 29 '13 at 06:40
12 Answers
There's the Android Cloud to Device Messaging framework (C2DM). It requires Android 2.2 or greater. If you require something that works with prior versions, Urban Airship has something that may suit your needs. I have used neither, so I can't say whether they are any good or not.
Edit:
Important: C2DM has been officially deprecated as of June 26, 2012. This means that C2DM has stopped accepting new users and quota requests. No new features will be added to C2DM. However, apps using C2DM will continue to work. Existing C2DM developers are encouraged to migrate to the new version of C2DM, called Google Cloud Messaging for Android (GCM).

- 35,607
- 26
- 136
- 135

- 14,482
- 7
- 57
- 72
-
C2DM has been replaced by the [Google Cloud Messaging framework](http://developer.android.com/guide/google/gcm/index.html) (GCM) which is vastly superior to C2DM: for example there are no more quotas, it is extremely efficient and very, very fast. You will need to create a third party server or use a service such as [AirBop](http://www.airbop.com) to track device registration ids and handle things like splitting your push requests into batches of 1000. – Lorne Laliberte Nov 28 '12 at 23:45
Standard way to show notifications in Android are Status Bar Notifications.
If you need to push notification from the server to devices you might want to take a look at Cloud to Device Messaging.

- 79,991
- 11
- 123
- 154
I have used this Functionality of Push Notification..
I had reffered http://developer.android.com/guide/google/gcm/gs.html link..
This works perfectly fine and you will definately learn a lot.
You just have to do according to instructions. and you will be able to perform Push Notification.

- 1,205
- 1
- 11
- 19
I once had a play with this project, when I was creating an application with a similar requirement (I needed to receive status updates from a remote hardware device):
http://tokudu.com/2010/how-to-implement-push-notifications-for-android/
There's a Stackoverflow topic about it here:
Push Notifications in Android Platform
The other possible answer is Google's own Android Cloud framework but I don't know the present status of this.
Many users will be turned off by your app popping up push notifications while it isn't running. The Android market and Amazon market handle update notifications for you, so unless you are using alternative distribution means, this may not be needed.
An alternative, less intrusive way is to have your app check for updates when it's actually run.

- 4,648
- 2
- 27
- 26
Free and easy method:
If your target user base is not large(less than a 1000) and you want a free service to start with, then Airbop is the best and most convenient.
Airbop Website It uses Google Cloud Messaging service through its API and is provides a good performance. i have used it for two of my projects and it was easy implementing it.
Services like Parse and Urbanship are excellent but paid and provide an entire deployment stack and not just the push notifications thing.
If only push service is your target, Airbop will work fine.
I haven't used Pushwoosh, but is also a great choice. It allows push to 1,000,000 devices.

- 658
- 2
- 8
- 20
Firebase (FCM) is Google's new (18/05/2016) way of sending push notifications on Android. Getting started guide

- 780
- 1
- 13
- 27
Step:- 1. Description :- Get an account from https://console.developers.google.com and then create one project and here this project have some unique id that we called senderid as well. Step:- 2. After that select project from left menu then you will see some features list. Step:- 3. then enable the api features for Google Cloud Messaging for Android. Step:- 4. now create the server Key(Application key) which can be generate from. Go to APIs & Auth and then inside Credentials after click on create new key BUTTON and generate Server key with out any IP address(No input) and use that Server Key(API Key) below applicationId.. step:- 5. Now follow this below code. Step:- 6. Pass DeviceId which will be RegId given By Android developer and passIt into DeviceId as Input string.
Following is Android push message to GCM server method
private Helpers.Response GCMAndroid(Notification notification)
{
var applicationID = " applicationID means google Api key"
var SENDER_ID = "SENDER_ID is nothing but your ProjectID (from API Console- google code)"
WebRequest tRequest;
tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send");
tRequest.Method = "POST";
tRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));
//string postData = "data.Alert=" + alertmessage + "&data.action-loc-key=" + actionKey + " ®istration_id=" + deviceId + "&badge=" + (1).ToString() + "";
var Details = JsonConvert.SerializeObject(notification.alertmessage);
string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message="
+ notification.alertmessage + "&data.time=" + System.DateTime.Now.ToString() + "&data.details=" + Details + "®istration_id=" + notification.deviceId + "";
try
{
Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
tRequest.ContentLength = byteArray.Length;
Stream dataStream = tRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse tResponse = tRequest.GetResponse();
dataStream = tResponse.GetResponseStream();
StreamReader tReader = new StreamReader(dataStream);
String sResponseFromServer = tReader.ReadToEnd(); //Get response from GCM server.`enter code here`enter code here`
enter code here
tReader.Close();
dataStream.Close();
tResponse.Close();
Helpers.Response Response = new Helpers.Response();
Response.Message = "Success";
Response.result = 1;
return Response;
}
catch (Exception ex)
{
Helpers.Response Response = new Helpers.Response();
Response.Message = ex.ToString();
Response.result = 0;
return Response;
}
}

- 16
- 3
Sending Push Notification using GCM is deprecated, Use Firebase Cloud Messaging (FCM)
Google deprecated the Google Cloud Messaging (GCM) and Lunched new Push notification server that is Firebase Cloud Messaging (FCM). FCM is same like GCM, FCM is also a cross-platform messaging solution for mobile platforms
Check this answer for More detail : How to add a push notification in my own android app

- 1
- 1

- 2,301
- 24
- 33
To send push notification in android application you need to create a project inside the firebase console once you create a project and you will be redirected to the project dashboard click on the android icon and add your android project package and save. You need to download google-services.json file which you need to add in your android project. You need to add firebase library in your project dependencies and sync your project.
You can read complete tutorial on implementation of Firebase push notification android

- 1,072
- 12
- 20