Starting our sample application in the background

After our sample application successfully creates a push session, it can call registerToLaunch() so that our headless application can start running in the background if it isn't already running when a push message arrives. The registerToLaunch() function is called in the onCreateSessionCompleted slot. In your application, if you try to call registerToLaunch() before you successfully create a push session, you'll get an error on the register to launch operation.

The register to launch flag is saved between application restarts only if we create a push channel or if the channel remains active. If we don't create a channel or the create channel operation fails, the register to launch flag isn't saved. When a channel is destroyed, the flag is lost.

If you don't want to start your application when a push message arrives, call unregisterFromLaunch(). The push messages that arrive after you call unregisterFromLaunch() are delivered only if your application is running when the messages arrive. Additionally, the default starting behavior for your application is unregisterFromLaunch(), so you would call unregisterFromLaunch() only if you called registerToLaunch() previously. For more information about registerToLaunch() and unregisterFromLaunch(), see the API Reference.

void AppHeadless::onCreateSessionCompleted(const 
   bb::network::PushStatus &status)

	QString message;
    if (status.code() == PushErrorCode::NoError) {
        if (m_shouldRegisterToLaunch) {
        } else if (m_shouldUnregisterFromLaunch) {

       message, status.code());

Last modified: 2013-12-21

comments powered by Disqus