Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Push Development

Reply
Developer
JeffFrancom
Posts: 15
Registered: ‎12-20-2012
My Device: BlackBerry 10 Dev Alpha
Accepted Solution

PushService: registerToLaunch

Hey guys,

 

I have been implementing Push services in my app and I have come across a bit of a speedbump. I used the community SimplePushClient as a base, and managed to properly receive and process Push messages. However, I can only receive the Push messages when the app is running. As soon as I close the app I can no longer receive pushes.

 

I run registerToLaunch once I have successfully created a channel, and I receive a confirmation that the app successfully registers, but as far as I can tell it is not working properly.

 

Below is my createChannelCompleted slot code:

 

void PushManager::createChannelCompleted(const bb::network::PushStatus& status,
		const QString& token) {
	Q_UNUSED(token);

	if (!status.isError() && m_pushService) {
		qDebug() << ("Channel creation completed successfully");
		m_pushService->registerToLaunch();
		emit(createChannelCompletedSignal(status, token));
	} else {
		qDebug() << ("Channel creation failed: " + status.errorDescription());
	}
}

 

And here is the slot for registerToLaunchCompleted:

 

void PushManager::registerToLaunchCompleted (const bb::network::PushStatus &status){
	if (!status.isError() && m_pushService) {
		qDebug() << ("Register creation completed successfully");
	} else {
		qDebug() << ("Register creation failed: " + status.errorDescription());
	}
}

 

The output when this is run gives me confirmation that the registerToLaunch has been successful:

 

Debug: receive message: @ipc
msg::smileysurprised:nRegisterToLaunchComplete
id::registerToLaunch_2340

Debug: err is 0
Debug: No dat section
Debug: Register creation completed successfully

 


So it appears to me that my code is sound and that everything is running properly, but as soon as I close the app I can no longer receive Push messages.

 

Anybody have an idea of what is going wrong here?

 

Thanks for any possible help,

 

- Jeff Francom

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: PushService: registerToLaunch

Did you get the SimplePushClient receiving push messages when closed successfully?

 

In your app, when a push is receievd does the app get launched in a minimized state?

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Developer
JeffFrancom
Posts: 15
Registered: ‎12-20-2012
My Device: BlackBerry 10 Dev Alpha

Re: PushService: registerToLaunch

SimplePushClient worked as expected, launching and receiving push messages when closed worked successfully.

 

In my app, when the push is received nothing happens. No invoke is received and the app is not launched.

Please use plain text.
Developer
JeffFrancom
Posts: 15
Registered: ‎12-20-2012
My Device: BlackBerry 10 Dev Alpha

Re: PushService: registerToLaunch

[ Edited ]

Well now it works properly. Zero changes to the code, but I did unplug the battery and leave the phone alone for the weekend. Now things seem to work just fine.

 

It appeared to be working properly, but it is slightly off. When it receives a push and the app is closed, it launches in a minimized state but does not pop the push. If a second push is received while the app is in the minimized state, it properly handles the received push (I did not notice the minimized launch before which caused me to read it as a false positive).

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: PushService: registerToLaunch

Sounds like a possible config issue with the app. Make sure you set up your InvokeManager to read in the push as a first step when the app is launched, delaying could cause the app to miss the InvokeRequest containing the Push Payload.

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Developer
JeffFrancom
Posts: 15
Registered: ‎12-20-2012
My Device: BlackBerry 10 Dev Alpha

Re: PushService: registerToLaunch

I am unsure what config issue there could be. I have checked my bar-descriptor countless times and nothing seems amiss. Is there a way to get the paylod from an InvokeManager when the app launches?

 

When the push arrives, the app gets launched but my onInvoked() slot never receives an InvokeRequest. I have used the InvokeManager::startupMode() to determine if the app was launched by the user or by an invoke and it is properly launched by an invoke when a push arrives. However, nothing happens beyond the launching of the app so the onInvoked slot never receives a signal.

 

I thought maybe there was an issue with my bar-descriptor, but if that was so would there not be issues in receiving pushes while the app was running as well?

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: PushService: registerToLaunch

If onInvoked is not being called when the app is launched from a push then the likely cause is that the slot connection is not being done early enough in the app. Are you doing anything (setting up UI, connecting BBM etc) before setting up the onInvoked slot connection?

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.
Developer
JeffFrancom
Posts: 15
Registered: ‎12-20-2012
My Device: BlackBerry 10 Dev Alpha

Re: PushService: registerToLaunch

That was exactly the issue. I moved the setup of my PushManager a few lines higher in my code and voila! Everything works fine. 

 

Thank you so much for the help, this has been plaguing me for a while.

 

- Jeff Francom

Please use plain text.
BlackBerry Development Advisor (Retired)
gbeukeboom
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10

Re: PushService: registerToLaunch


JeffFrancom wrote:

That was exactly the issue. I moved the setup of my PushManager a few lines higher in my code and voila! Everything works fine. 

 

Thank you so much for the help, this has been plaguing me for a while.

 

- Jeff Francom


Glad I could help :smileyhappy:

Garett
@garettBeuk
--
Goodbye everybody!
Please use plain text.