Click here to Skip to main content
Click here to Skip to main content

Pushing HTML content to a Blackberry

, 7 Dec 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
How to push HTML content to a blackberry handheld using MDS

Blackberry showing pushed HTML content

<!------------------------------- STEP 3 ---------------------------><!-- Add the article text. Please use simple formatting (

,

etc) -->

Introduction

Blackberry's (developed by Research In Motion - RIM) have become a critical part of many corporate networks including IT, financial and government networks.  Their always connected nature and rich content delivery services (through Blackberry Enterprise Server and Mobile Data Service) make them very inviting to developers to develop applications for.  Out of the box, you can deliver HTML content to them with very little work.  Their Java-based operating system allows for developers to create applications that deliver data in real time and can be interacted with using the devices intuitive user interface and full QWERTY keyboard.

I am going to concentrate on the most simplistic way to delivery content to the device using a HTML browser channel.   My next article may include a custom application for the handheld.

In order to use this code you need

  1. A Blackberry Enterprise Server 4.0 or above
  2. A Blackberry handheld running the 4.0 operating system or above
  3. The IPPP service book installed (automatically installed through Enterprise Activation)
  4. IIS 5 or above to run the WebService I have created

How It Works

The Mobile Data Service is completely HTTP based. You establish an HTTP connection to your Blackberry Enterprise Server (default port is 8300) with some query parameters and POST containing your data.  The handheld's browser listens on port 7874 for incoming pushes.  Custom Blackberry HTTP headers specify information about the content and how to display it (including read and unread icons, title, etc).  For simplicity sakes, I am going to let the handheld use its default icons. 

Using the code

I decided to implement this as a WebService to allow for easy access from other internal applications.  The code is pretty straight forward.  There is one WebService method and one protected method that handles actually creating the HTTP request and firing it off to the MDS server. Configuration information about the MDS server is held in web.config and can be accessed using the built in ConfigurationSettings.AppSettings collection.

The WebService method has the following signature:

public virtual void PushToBrowser(string[] recipients, <BR>                                  string channelTitle, <BR>                                  string channelName, <BR>                                  string baseLocation, <BR>                                  string message)

To use, create a new application, add a web reference to it (I called mine BesUtils).  The code below illustrates how you'd push a simple HTML document to a handheld

BesUtils.MdsPusher pusher = new BesUtils.MdsPusher();

string[] recip = {"steven@mbccs.com"};

try
{ 
    pusher.PushToBrowser(recip, "Hello World", Guid.NewGuid().ToString(), <BR>               "", "<html><head></head><body>Hello World.</body></html>");
}
catch(Exception ex)
{
    Console.Write(ex.ToString());
} 

The image at the top of this article illustrates the icon and text that appears when a new message has been pushed to the handheld. You would click the icon to open the browser and it would take you directly to the document you pushed down.

Points of Interest

You need to keep channelName constant if you want the handheld to update the same channel, otherwise a new channel will be created each time you push to the handheld.

History

  • December 7, 2004 - First version of article published,

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Steven Berkovitz
Web Developer
Canada Canada
Steven is VP Development at MBC Computer Solutions Ltd. (http://www.mbccs.com), a Richmond Hill based company specializing in e-Business Application Development, e-Store Solutions, Managed Co-Location and Proactive IT services.
 
Steven has over 10 years experience in software and hardware design and is experienced with a large array of platforms, technologies and languages.
 
In his spare time, Steven enjoys a wide array of music, is an avid skier and enjoys spending time with friends.
 
Steven is the primary contributor of MBC's blog which can be read at http://blogs.mbccs.com/mbccomputersolutions

Comments and Discussions

 
Questioni want send message to blackberry from windows desktop application Pinmembersriram30308-Aug-07 20:20 
GeneralBES Server Setting PinmemberSubraS24-May-06 10:40 
GeneralRe: BES Server Setting PinmemberSteven Berkovitz24-May-06 10:56 
GeneralRe: BES Server Setting PinmemberSubraS24-May-06 11:02 
GeneralRe: BES Server Setting PinmemberSteven Berkovitz24-May-06 11:03 
GeneralRe: BES Server Setting PinmemberSubraS24-May-06 11:32 
Steve,
thanks again. The options where unchecked. The browser port is 8300 and the push port is 8100; i changed this setting in web.config and now I am getting this message:
System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetRequestStream()
at Blackberry.BesUtilities.MdsPusher.SendToHandheld(String recipient, Int32 devicePort, IDictionary requestHeaders, Boolean htmlMessage, String message) in c:\inetpub\wwwroot\blackberry\mdspusher.asmx.cs:line 102
at Blackberry.BesUtilities.MdsPusher.PushToBrowser(String recipients, String channelTitle, String channelName, String baseLocation, String message) in c:\inetpub\wwwroot\blackberry\mdspusher.asmx.cs:line 70
 
thanks again.
QuestionHow to Remove newly created channels Pinmemberdrex300022-Feb-06 6:48 
AnswerRe: How to Remove newly created channels PinmemberSteven Berkovitz22-Feb-06 12:27 
GeneralRe: How to Remove newly created channels Pinmemberdrex300023-Feb-06 6:44 
GeneralRe: How to Remove newly created channels PinmemberSteven Berkovitz23-Feb-06 6:46 
GeneralGET Data Pinmembercberam4-May-05 20:12 
GeneralFYI - download the simulator PinsussAnonymous15-Dec-04 4:11 
GeneralRe: FYI - download the simulator PinmemberSteven Berkovitz15-Dec-04 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1411023.1 | Last Updated 7 Dec 2004
Article Copyright 2004 by Steven Berkovitz
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid