Download, build, and deploy the sample app
To download the sample app, visit the samples repository. The repository contains the source code and associated files for the app. The README.md file in the repository contains the instructions that you need to build and deploy the sample app on a BlackBerry device.
The repository contains the following folders:
|Images||This folder contains the images for the sample app.|
|Styles||This folder contains the CSS files for the sample app.|
Configure the sample app
When you run the sample push-enabled app for the first time, you need to specify some configuration information, including the information from the confirmation email message that you received when you registered your Push Initiator to use the Push Service. When you develop your own app, you can hard code this information into your app instead of displaying it in a configuration screen and requiring the user to type the information.
Start the sample app.
The configuration screen appears.
- Click Public/BIS if you're using the Push Service without the BlackBerry Enterprise Service or Enterprise/BDS if you're pushing data through the BlackBerry Enterprise Service.
Clear the Subscribe with Push Service
SDK check box if one of the following is true:
- Your Push Initiator doesn't use the Push Service SDK.
- Your Push Initiator only uses the low-level APIs without subscription support from the Push Service SDK.
- You’re using the low-level sample Push Initiator that comes with the Push Service SDK.
If the Subscribe with Push Service
SDK check box is selected, in the Application ID field, perform one of the following
- Type the application ID that is specified in the confirmation email message that you received from BlackBerry.
- If you're pushing data through the BlackBerry Enterprise Service, type a unique application ID of your choosing. If you clear the Subscribe with Push Service SDK check box, you can't type an application ID. In this case, the Push Service APIs create an application ID for you automatically.
The sample app uses the application ID when it creates the PushService object to perform push-related operations. To specify the application ID in your own app, you use the appId field of the options object that is passed into the call to the static PushService.create() function.
In the PPG URL field, type the PPG
base URL specified in the confirmation email message. The sample app uses this
URL to create a channel to the PPG. If you're using the push technology of the
BlackBerry Enterprise Service, you don't need to type a URL.
For an evaluation environment, the URL is http://cp<cpid>.pushapi.eval.blackberry.com, where <cpid> is your content provider ID. For a production environment, the URL is http://cp<cpid>.pushapi.na.blackberry.com.
- If the Subscribe with Push Service SDK check box is selected, in the Push Initiator URL field, type https://<server_address>/high-level-sample, where <server_address> is the address of the server where the high-level sample Push Initiator is deployed. The Push Service SDK includes the high-level sample Push Initiator that is deployed on the Apache Tomcat server. The URL must be accessible from the Internet.
- Click the Launch Application on New Push check box if you want to start the sample app if it isn't already running when a new push message arrives. Leave the check box cleared if you don't want to start the sample app when a new push message arrives. If the check box is cleared, and the app isn't running, it won't receive the push message.
The sample app stores the configuration in the database, and calls the static PushService.create() function to attempt to create a PushService object. If the PushService.create() call is successful, the app calls launchApplicationOnPush() with true or false depending on the selection you made for the Launch Application on New Push option on the configuration screen. For details about these calls, see Creating a PushService object and Start the sample application in the background.
Register the sample app
After you configure the sample push-enabled app, you need to register the app 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 app, the Push Initiator requires a username and password that it authenticates before allowing the subscription. The sample app provides a Register dialog box where you can type any username and password.
To see the code that creates the channel and handles the subscription, see Creating a push channel.
Tap Register at the
bottom of the device screen.
The Register screen appears.
- If you chose to subscribe with the Push Service SDK, type any username and password in the Register screen.
- Tap Submit.
Last modified: 2014-03-10