Developing a push-enabled application
You can use the sample application to learn how to develop your own push-enabled application. The sample application shows you how to use the Push Service APIs to connect with the Push Initiator, and receive push messages on a BlackBerry device.
The sample application accepts push messages with the following types of content. If you're using the Push Service SDK as the server-side library, the SDK automatically specifies the type of content in the header of the push message. In your application, you can send up to 8 KB of any type of content (images, text, or audio).
| Type of content | Content-type HTTP header |
|---|---|
| Text | text/plain |
| HTML | text/html |
| XML | application/xml |
| Image | image/jpeg, image/gif, image/png |
If you implemented a Push Initiator that doesn't use the Push Service SDK, or your Push Initiator only uses the low-level APIs without subscription support from the SDK, you can still use the sample application for testing purposes. You just need to indicate that you're not going to subscribe with the Push Service SDK when you configure the sample application. For details, see Configure the sample application.
Requirements
| Item | Requirement |
|---|---|
|
Server-side library |
We recommend using the Push Service SDK with our sample push-enabled application, and with push-enabled applications that you develop. To use the Push Service with the BlackBerry Internet Service, you must register with Research In Motion. When you sign up, you receive a confirmation email message that contains information that your application uses to create a session and create a channel. For more information about signing up, visit Push Service. If you plan to develop a push solution that delivers content using the BlackBerry Device Service only, you don't need to sign up to use the Push Service. |
|
Client-side library |
BlackBerry 10 WebWorks SDK |
|
BlackBerry device |
|
|
Sample push-enabled application |
BlackBerry 10 WebWorks SDK |
Download and build the sample application
To download the sample application, visit the samples repository. The repository contains the source code and associated files for the application. The README.md file in the repository contains the instructions that you need to follow to build and deploy the sample application on a BlackBerry device.
The repository contains the following folders:
| Folder | Description |
|---|---|
| Images | This folder contains the images for the sample application. |
| Scripts | This folder contains the JavaScript files for the sample application. |
| Styles | This folder contains the CSS files for the sample application. |
Configure the sample application
Register the sample application
After you configure the sample push-enabled application, you need to register the application to create a push channel to the PPG to receive push messages.
If you chose to subscribe with the Push Service SDK when you configured the sample application, the Push Initiator requires a username and password that it authenticates before allowing the subscription. The sample application provides a Register dialog box where you can type any username and password.
To see the code in the sample push-enabled application that creates the channel and handles the subscription, see Creating a push channel.
Update your config.xml file
Before you can use the Push Service APIs with your application, you need to update your application's config.xml file with the following statements. The sample application already has these statements, so you don't need to add them before using the sample application.
