Keeping your users updated
Proactive and notification-driven apps are fundamental to the BlackBerry 10 experience. By providing your users with new information and content regularly, you encourage them to come back to your app again and again. One of the important aspects of keeping your users updated is efficiency. You want to make sure that you're able to push content to the device without draining resources and wasting battery life.
In Cascades, there are a few different ways that you can retrieve remote data. The first one we look at is networking.
Networking in Cascades is handled by the QtNetwork module. The module exposes a mix of low-level and high-level APIs to simplify sending data over the network.
High-level network operations are primarily handled by the QNetworkAccessManager API, which is responsible for sending requests, monitoring progress, and handling results. Low-level TCP operations can be handled using QTcpSocket and QTcpServer.
Applications that must update content frequently might want to avoid this approach. Repeatedly polling a server for new content can waste battery life, even when there is no new data available. In these cases, the Push Service should be considered as an alternative approach to retrieving new data.
Unlike standard networking, which requires that the app poll a server for new data, the Push Service allows your app to listen for updates. With the Push Service, you can deliver up to 8 KB of content (images, text, or audio) to many devices at once. The content is sent to the general public using the BlackBerry Internet Service, or to enterprise users using the BlackBerry Device Service. Content delivered using the Push Service is available to users without waiting for downloads.
Here's a diagram of how the Push Service solution delivers content to a push-enabled app.
The Push Service is a great way update your users, and offers end-to-end message visibility. The Push Service requires minimal coding, runs in the background, and has a minimal drain on the battery.
Another useful tool for retrieving data over the network is a headless app. Headless apps are components that run in the background, which you can use to perform operations like connecting to an external service, or listening for new content using the Push Service. Some of the processes that are suitable for headless apps are as follows:
- VoIP functionality
- Downloading content or connecting to remote services
- Responding to BlackBerry 10 device accessories
- Tracking location changes
- Playing back audio
Here's an overview of how a headless app notifies the UI app with updates.
Multiple headless app components can be running at a given time, but you need to pay close attention to your implementation. Running too many headless processes, or running them for too long, can have a detrimental impact on user experience and battery life. Because of this impact, the use of headless app components is subject to a set of strict rules and constraints enforced by the platform to protect overall user experience.
After your app receives new data, your app will probably need to store it. Cascades uses a modular approach to store, access, and display data within your app. Supported data types include JSON, SQL, and XML formats.
The following diagram illustrates the different components that interact when you manipulate data in your app:
Apps that need to store information in the cloud can use cloudbase.io. The cloudbase.io service is a cross-platform service that allows you to store data remotely and push it to your users whenever you need to. You can send and receive data between the app and the server, log information about usage, and even configure cloudbase.io to work with the Push Service.
After your app receives new data, you need to be able to notify the user that new content has arrived. Notifications can come in a number of different forms, such as adding a splat to the app's icon on the home screen, using the LED, or delivering the notification to BlackBerry Hub.
Notifications in BlackBerry Hub
Notifications in BlackBerry Hub are created using the Notification class. The Notification object can specify content such as the title, body, and sound for the notification. The notification can be configured to flash the LED, play a sound, and display a splat on the app icon. After the notification is triggered, users can view and respond to the notification directly within BlackBerry Hub.
You can use a NotificationDialog to display a dialog box when an urgent event occurs. A NotificationDialog contains the same content as a Notification, but with more properties for displaying the dialog box.
Learn how to enrich the content for your app by Adding graphics and multimedia.
Last modified: 2015-03-31