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
pfluger
Posts: 100
Registered: ‎02-10-2009
My Carrier: T-Mobile

User opening app on BB10 while incoming push InvokeRequest being handled

We have a BB10 Cascades app with push support. We are seeing the following problem.

 

The app has set registerToLaunch to true. When the app is closed and a push comes in, the app is started in the background and receives the push InvokeRequest.

 

The app needs a couple of seconds to do some network communication and depending on the results will trigger a Notification.

 

The problem is that while the push is being handled in the app, the user cannot launch the app from homescreen. Clicking the icon simply does nothing.

 

As soon as the app exits using Application::quit() everything is back to normal and clicking the icon will open the app.

 

Unfortunately the time of the notification is usually exactly the time the user wants to open the app by either opening the notification from the hub or from the homescreen.

 

I am not seeing any other InvokeRequest or anything coming in when the icon is clicked.

 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Carrier: Rogers

Re: User opening app on BB10 while incoming push InvokeRequest being handled

Hi,

 

A few questions to hopefully better understand your issue:

1. You mentioned that the results will trigger a "Notification".  Are you referring to a notificaiton entry in the BlackBerry Hub?  Are you creating this notification as part of your processing of the push?  Typically, creating the notification itself should be one of the last things you do when processing the push.  Heavy processing should also be avoided while processing a push if possible.

 

2. Which verison of the Dev Alpha device are you testing with?  There are some lags and delays you might see in these devices that you would not typically see in production grade BlackBerry 10 devices.  I mention this, because in our Push Collector sample app, the processing of the push seems to be really quick.  The app is open, processes the push, and exits in a matter of milliseconds.

 

3. Have you tried the Push Collector sample app on your device?  Are you seeing the problem with the sample as well or is it unique to your app?

 

4. What version of the OS version do you have loaded on your device?

 

Thanks,

 

Matt

Please use plain text.
Developer
pfluger
Posts: 100
Registered: ‎02-10-2009
My Carrier: T-Mobile

Re: User opening app on BB10 while incoming push InvokeRequest being handled

There is no problem in the OS part of processing the push. Simply receiving a push and triggering a BlackBerry Hub notification only takes a couple of milliseconds just as you say. Everything is fine in this case.

 

The problem is that we are using a "push-to-pull". So the push notifications triggers data downloads in the app which inherently can take a couple of seconds or longer. This data determines if and what notification we want to put into the Hub. We obviously have to wait until the downloads are all done before we can quit the app. During this time the user can't launch the app.

 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Carrier: Rogers

Re: User opening app on BB10 while incoming push InvokeRequest being handled

Hmm, how are you downloading the data?  We've been doing a few tests just now where processing is done asychronously and it seems to be working, but we'll fiddle it with some more.

Please use plain text.
Developer
pfluger
Posts: 100
Registered: ‎02-10-2009
My Carrier: T-Mobile

Re: User opening app on BB10 while incoming push InvokeRequest being handled

We start a regular event loop first using Application::exec() and then download the data using something like this:

 

QString queryUri = "http://...";

QNetworkAccessManager* netManager = new QNetworkAccessManager();
QUrl url(queryUri);
QNetworkRequest req(url);
	
QNetworkReply* ipReply = netManager->get(req);
connect(ipReply, SIGNAL(finished()), this, SLOT(onDataReply()));

We are then waiting for onDataReply slot. 

 

For testing we have added some delay to the server responses (on the server side).

 

When clicking the icon on the homescreen while the app is running and waiting for data replies clicking the icon only dims it slightly but doesn't do anything else.

 

 

Please use plain text.
Developer
pfluger
Posts: 100
Registered: ‎02-10-2009
My Carrier: T-Mobile

Re: User opening app on BB10 while incoming push InvokeRequest being handled

BTW, what we expected is to receive an InvokeRequest  with some kind of "launch GUI" action if the user tries to launch the app while we are processing the push request. We would then initialize and show the GUI.

 

It works the other way around. When the UI is visible because the app is regularly running and a push request comes in we receive the push InvokeRequest.

Please use plain text.
BlackBerry Development Advisor (Retired)
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Carrier: Rogers

Re: User opening app on BB10 while incoming push InvokeRequest being handled

Where are you putting this code?  It should be in your function handling the incoming push I would think.

 

You still need to initialize your application and GUI as the user can bring it to the foreground at any point they want.

 

What Dev Alpha device are you testing this on?  A or B?  

What OS are you running on the device?

 

Thanks,

 

Matt 

Please use plain text.
Developer
pfluger
Posts: 100
Registered: ‎02-10-2009
My Carrier: T-Mobile

Re: User opening app on BB10 while incoming push InvokeRequest being handled

In the main() function we check if the app has been launched through an InvokeRequest

 

	bool showUi = true;
	InvokeManager invokeManager;
	switch(invokeManager.startupMode()) {
	    case ApplicationStartupMode::LaunchApplication:
	    	qDebug() << "Regular application launch";
	        break;
	    case ApplicationStartupMode::InvokeApplication:
	    	qDebug() << "Launching app from invoke";
	    	showUi = false;
	        break;
	    default:
	        // Who am I and how did I get here?
	        break;
	    }

If it was launched through an InvokeRequest we do not initialize the UI (i.e. don't load any QML and don't call Application::setScene). Apart from that the app does all regular initializiation like loading settings and any persistent data.

 

We connect the invoked signal of the InvokeManager. Once we receive the signal we do the download using code similar to the one I posted earlier.

 

 

We tried initializing the UI, but this will pop up our active frame on the homescreen for a couple of seconds which would be very confusing to the customer. Launching the app from the homescreen icon works in this case though.

 

Tested this on both Dev Alpha A and B. OS version 10.9.9.339

Please use plain text.
BlackBerry Development Advisor (Retired)
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Carrier: Rogers

Re: User opening app on BB10 while incoming push InvokeRequest being handled

After discussing your current implementation with our developer that wrote the Push Collector sample, he said that he would recommend initializing the UI in the main function like Push Collector does.  You would connect your invoke signal to the slot in your constructor call:

App::App()
    : m_invokeManager(new InvokeManager(this))
{
// …
    // connect to InvokeManager "invoked" signal to handle incoming push notifications.
    // We will ignore non-push invoke requests.
    connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)),
            SLOT(onInvoked(const bb::system::InvokeRequest&)));
// …
}

 

You would then do your downloading stuff in your slot implementation.

 

And, yes, the app does show up briefly on the running app grid and then typically exits after processing, but that shouldn't be a big deal.  If they click on the app before it exits, then it will bring it to the foreground and won't exit (which is what a user would expect).

 

If you would prefer to keep with your current implementation, you can post a question on the Cascades support forum:

http://supportforums.blackberry.com/t5/Cascades-Development/bd-p/Cascades

Someone might be able to help you more there since this is more a Cascades-related issue than a push one.

 

Thanks,

 

Matt

 

Please use plain text.