Monday, December 23, 2013

Nuget Package for Push Notification on Android and iOS

Continue to my previous post for Push Notification, I have generated a simplified process to implement Push notification for iOS and Android.

Anyone can download my Nuget package from

To install Push Notification for Android and iOS, run the following command in the Package Manager Console
PM> Install-Package EasyPushNotification

Web.config settings

Add following keys into AppSettings into web.config file.

        <add key="APIKey" value="SOME_API_KEY"/>
        <add key="ApnsCertPath" value="CERTIFICATE_PATH"/>
        <add key="ApnsCertPassword" value="CERT_PASSWORD"/>

For Android
APIKey    is API key provided by GCM server. Follow the steps from here to generate project and obtain API key. The generated Project ID will be used to generate Device Token from Android devices.
For iOS
ApnsCertPath is the physical path where iOS apns certificate is stored. This should be a located into server and the path should be something like "~/Certificate_Folder/Certificate_Name.p12” follow the steps from here to generate certificate. (iOS developer might have better ideas how to generate certificate.)

ApnsCertPassword is password for certificate generate from above step.

Call Method

Use below code block to raise push notification.
string DeviceID = string.Empty;
string Message = string.Empty;
DeviceType DeviceType = DeviceType.Android;

NotificationInfo objNotificationInfo = new NotificationInfo();
bool result = objNotificationInfo.SendNotification(DeviceID, Message, DeviceType);

                DeviceID is Device token generate using phone and stored into database table using a service call. 
                Message is string variable. The message is to be displayed as notification.
                DeviceType is an Enum variable to decide whether the device is Android or iOS device. Fetch Device type from database which as stored with DeviceToken using service.
Method will return Boolean result as success or failed.
ProcessResult will provide handled exception message.

isError is Boolean variable to indicate any error occurs.

Happy Mobilizing.. 

Tuesday, November 19, 2013

Push Notification for Android


Now a Days in era of smart phones and mobile app developments, a very important feature is "Push Notification".

For any Mobile app (Android, iPhone, Blackberry, etc.) Push Notification is part of requirement and complete project.
To know more about Push notifications please Google !! here is a quick Wikipedia link.

In this post I am going to demonstrate Push notification for Android phones. As of now I don't have any Android device connected with my machine so can't get snapshots of result but one can trust me that whatever I have implemented is fully working.

OK.. So Let's Start ..........

  1.  Create an application .(whatever you like..MVC, or anything) 

                       I hope you are aware about NuGet Package Manager. if not refer official website of NuGet. visual Studio 2010 + comes up with inbuilt support of NuGet Packages. still can't find NuGet Packages into your Visual Studio Install from Website.
  2. Once You are done with Above step, Right click on Solution of project. and Select "Manage NuGet Packages for Solution.."

  3. "Manage NuGet Package" window will appear. 
  4.  Thanks to "Redth", who has provided us a very useful NuGet Package Named "PushSharp"search from Right top search window for "PushSharp"  and Select the First Package.

  5. Click on "Install" Button. If Prompts to "Select Project", Select the Projects in which you would like to add reference of PushSharp library.Click OK.
  6. Here we go.. Nuget Package Installation will start and wait until is completes.

  7. Close all other open window. you can track output windows whether installation completed successfully. You can check in Project Reference, whether new references of PushSharp are assigned or not. If everything is good then let's move ahead Or feel free to post your problem. I will try my best to support you.

Now It's Time to create Project for Android Push Notification.

Please Follow the article to Create and Configure (you might find some changes as recently Google has changed API Console UI. So try to push more efforts to understand)
Alright, I hope You have successfully Created Android API Project. It's very important part for Android push notification. 
You might have come across two important Key works while creating Project.
  1. Project Number : is used to generate Device Token from Android Device. The Project number keeps track of the notification raised for particular device consumes for which Project ID. You have to provide the Project number to Android phone developer. They will use the project number and Provide Device Token.

  2. API key : API key secured key mandatory to pass while processing notifications.

Keep this information somewhere stored.

Now There are three important credentials  required to accomplish Push notification for Android.
  1. Device Token : using Project Number, Android Phone developer can provide the Device Token. I have no Idea how they does.. 
  2. API Key : The API key provided by Project.
  3. Message: The message to be passed on as Push Notification.
Basically, Some implicit or explicit action required to raise the Notification. In My Case I used to created a WCF Restful service (Sample Application). We had a message with minor database parameters to be passed. So Whenever the notification was supposed to raise, phone developers were making a request on my WCF service with Device Token as Parameter.

Here is code block to raise notification. Very short and simple !! :)

var push = new PushBroker();            
push.RegisterGcmService(new GcmPushChannelSettings(APIKey));            
push.QueueNotification(new GcmNotification().ForDeviceRegistrationId(DeviceTokenID)
                .WithJson("{\"message\":\"" + Message + "\"}")); 

That's all. Done..

I have done few more push notification also using PushSharp.
Please feel free to contact me for any kind of assistance.

Wednesday, August 21, 2013

Custom Message box and Confirm window all in one

I have created a custom message box and confirm window which can be used in all programming languages and all platforms.
syntex :
AlertCust([Control], {Message Title}, [Message Text], {IconType}, {PromptType}, [OnOk], [OnCancel]);

Description :

  • [Control] : Optional, Pass the control which raises the prompt. in Confirm or Alert window when click ‘OK’ button is clicked, the default server event will be executed, if value is passed. if null, clicking on ‘OK’ the prompt window will be closed, no further action.
  • {Message Title} : Required, Message Title. Title will appear in bold font.
  • [Message Text] : Optional, Message text in second line, in normal fonts.
  • {IconType} : Required, Enum values. pass icon type to display icon specific to message. options Error, Warning, Information
  • {PromptType} : Required,  This property helps to decide what kind of prompt we need. e.g. Validation, MessageBox(OkOnly), OKCancel, YesNo.
  • [OnOk] : Optional, To provided custom callback method, set javascript method name, will be executed when clicked ‘OK’.
  • [OnCancel] : Optional, To provided custom callback method, set javascript method name, will be executed when clicked ‘Cancel’.


anyone can download code from Here