PushService
Since: BlackBerry 10.0.0
#include <bb/network/PushService>
To link against this class, add the following line to your .pro file: LIBS += -lbbnetwork
Manages all interactions with the Push Proxy Gateway (PPG).
A PushService allows a push-enabled application to send requests to the PPG.
The PushService supports both sending requests and receiving responses from the PPG. Applications that receive response messages while they are running are notified via the [command]Completed() signal.
destroyChannel
The application can send an application level acknowledgement that indicates whether the application accepted or rejected the pushed content ( acceptPush() or rejectPush() ).
Overview
Properties Index
bb::network::PushCommand::Type | command [read-only] |
bool | hasConnection [read-only] |
QString | providerApplicationId |
QString | targetKey |
Public Functions Index
PushService (QObject *parent=0) | |
PushService (const QString &providerApplicationId, const QString &targetKey, QObject *parent=0) | |
virtual | ~PushService () |
bb::network::PushCommand::Type | command () const |
Q_INVOKABLE bool | hasConnection () const |
QString | providerApplicationId () const |
Q_INVOKABLE bool | reconnect () |
QString | targetKey () const |
Public Slots Index
void | acceptPush (const QString &payloadId) |
void | createChannel (const QUrl &pushProxyGatewayUrl) |
void | createSession () |
void | destroyChannel () |
void | registerToLaunch () |
void | rejectPush (const QString &payloadId) |
void | setProviderApplicationId (const QString &providerApplicationId) |
void | setTargetKey (const QString &targetKey) |
void | unregisterFromLaunch () |
Signals Index
void | connectionClosed () |
void | createChannelCompleted (const bb::network::PushStatus &status, const QString &token) |
void | createSessionCompleted (const bb::network::PushStatus &status) |
void | destroyChannelCompleted (const bb::network::PushStatus &status) |
void | pushTransportReady (bb::network::PushCommand::Type command) |
void | registerToLaunchCompleted (const bb::network::PushStatus &status) |
void | simChanged () |
void | unregisterFromLaunchCompleted (const bb::network::PushStatus &status) |
Properties
Public Functions
Creates a new PushService object.
Parameters | |
---|---|
parent |
The QObject that will take ownership of this object, or NULL. |
BlackBerry 10.0.0
Creates a new PushService object.
Parameters | |
---|---|
providerApplicationId |
The unique identifier of the push-enabled application. |
targetKey |
The invocation target key. |
parent |
The QObject that will take ownership of this object, or NULL. |
BlackBerry 10.0.0
virtual
Destructor.
BlackBerry 10.0.0
bb::network::PushCommand::Type
Retrieves the last failed command.
The returned value can be either a CreateChannel or DestroyChannel.
The last failed command as specified in PushCommand.
BlackBerry 10.0.0
Q_INVOKABLE bool
Determines whether the PushService has a connection to the Push Agent.
true if the PushService has a connection to the Push Agent, false otherwise.
BlackBerry 10.0.0
QString
Gets the provider application ID.
The provider application ID.
BlackBerry 10.0.0
Q_INVOKABLE bool
Reconnects the PushService to the Push Agent.
true if the PushService was able to reconnect to the Push Agent, false otherwise.
BlackBerry 10.2.0
QString
Gets the target key associated with this PushService.
The target key associated with this PushService.
BlackBerry 10.0.0
Public Slots
void
Accepts a push message.
If the Push Initiator requires an application level acknowledgement for a particular push message, this function sends an affirmative message back to the PPG to indicate that the application accepted the pushed content.
Parameters | |
---|---|
payloadId |
The unique identifier of the push notification which is stored in the PushPayload object. |
BlackBerry 10.0.0
void
Creates a channel for receiving push messages from the Push Initiator.
Once the channel is successfully established, the application does not have to call this again. The PushService maintains the channel. However, there are some cases where you might have to create the channel again (for example, if the SIM card is removed from the device).
Parameters | |
---|---|
pushProxyGatewayUrl |
The URL of the Push Proxy Gateway (PPG). |
BlackBerry 10.0.0
void
Creates a session between the application and the Push Service Notification agent (PNS agent).
Creating a session sets up inter-process communication between the application and the PNS agent. This must be called every time the application is launched.
BlackBerry 10.0.0
void
Destroys the channel when the application no longer needs it.
BlackBerry 10.0.0
void
Registers the application to be launched in the background upon receiving a push message.
BlackBerry 10.0.0
void
Rejects a push message.
If the Push Initiator requires an application level acknowledgement for a particular push message, this function sends a negative message back to the PPG to indicate that the application rejected the pushed content. This generally means that the Push Initiator should try to resend the push message. If the Push Initiator did not request an acknowledgement, this function does nothing.
Parameters | |
---|---|
payloadId |
The unique identifier of the push notification which is stored in the PushPayload object. |
BlackBerry 10.0.0
void
Changes the provider application ID represented by this object.
Parameters | |
---|---|
providerApplicationId |
The provider application ID |
BlackBerry 10.0.0
void
Changes the target key represented by this object.
Parameters | |
---|---|
targetKey |
The target key |
BlackBerry 10.0.0
Signals
void
Emitted when the connection to the Push Agent has been deleted.
When this happens, the application needs to re-establish the connection with the Push Agent by calling reconnect() periodically until reconnect() returns true. After reconnect() returns true, the application must then call createSession().
BlackBerry 10.2.0
void
Emitted when a response to the createChannel() request is received.
Parameters | |
---|---|
status |
A PushStatus response for the createChannel() request call |
token |
The token received from the PPG after successfully creating the push channel. This token should be communicated to the Push Initiator. |
BlackBerry 10.0.0
void
Emitted when a response to the createSession() request is received.
Parameters | |
---|---|
status |
The PushStatus response for the createSession() request call |
BlackBerry 10.0.0
void
Emitted when a response for the destroyChannel() request is received.
Parameters | |
---|---|
status |
A PushStatus response for the destroyChannel() request call. |
BlackBerry 10.0.0
void
Emitted when a previous createChannel() or destroyChannel request failed with a TransportFailure (10103) or SubscriptionContentNotAvailable (10110) status code.
Here's an example of how to initiate the requests again after they fail:
if (command == bb::network::PushCommand::CreateChannel) { pushService->createChannel(pushProxyGatewayUrl); } else if (command == bb::network::PushCommand::DestroyChannel) { pushService->destroyChannel(); }
Parameters | |
---|---|
command |
The last command that failed (either a CreateChannel or DestroyChannel). |
BlackBerry 10.0.0
void
Emitted when a response for the registerToLaunch() request is received.
Parameters | |
---|---|
status |
A PushStatus response for the registerToLaunch() request call. |
BlackBerry 10.0.0
void
Emitted when the SIM card is changed.
When this happens, the PPG stops delivering push messages. To continue receiving content, you must call createChannel() again.
BlackBerry 10.0.0
void
Emitted when a response for the unregisterFromLaunch() request is received.
Parameters | |
---|---|
status |
A PushStatus response for the unregisterFromLaunch() request call. |
BlackBerry 10.0.0