Pushing HTML Content to a BlackBerry | CodeGuru

Pushing HTML Content to a BlackBerry

Introduction BlackBerries, 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. Out of the box, you can […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 16, 2006
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Introduction

BlackBerries, 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. Out of the box, you can deliver HTML content to them with very little work. Their Java-based operating system allows developers to create applications that deliver data in real time and can be interacted with using the device’s intuitive user interface and full QWERTY keyboard.

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

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, and so forth). For simplicity’s sake, I will let the handheld use its default icons.

Advertisement

Using the Code

I decided to implement this as a Web Service to allow easy access from other internal applications. The code is pretty straightforward. There is one Web Service 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 Web Service method has the following signature:

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

To use it, create a new application and 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(),
                        “”, “<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.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.