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
Curahee
Posts: 229
Registered: ‎01-12-2013
My Device: z30

App automatically opens after push

Ok, so far so good.

 

I managed to get everything working. My app registers himself with my own written NodeJS push initiator and I can push messages from the push initiator to my device.

 

But I noticed that if the push message arrives on my device, and the app is not open, he automatically opens the app in an active frame. Can I prevent this from happening? I only want my notification to appear in the hub, so I handle the invoke of the InvokeManager

 

void PushManager::handleInvoke(const bb::system::InvokeRequest& request) {
	if (request.action().compare("bb.action.PUSH") != 0) {
		return;
	}

	bb::network::PushPayload payload(request);

	if (payload.isValid()) {
		if (payload.isAckRequired()) {
			this->pushService->acceptPush(payload.id());
		}

		Notification* notification = new Notification(this);
		notification->setTitle("Flu**bleep**");
		notification->setBody(payload.data());

		notification->notify();
	}
}

 So is it possible to prevent the app from opening? Or is there another way to make a notification in the hub from a push message?

 

Thanks in advance!

______________________________________________________
BB10-OAuth: GitHub
Retired
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Device: BlackBerry Z10

Re: App automatically opens after push

In the current BlackBerry 10 OS, processing a push will always launch the application to the background (if you had registered to launch of course - if you did not register to launch, the push will be dropped if it comes in and the application is closed).

 

The recommended best practice is to exit your application after processing a push message.

So, you would process the push, create your notification in the Hub, and then exit the application (if and only if the user did not bring the application to the foreground during the processing).

 

The following links talk about how to do both of these:

http://developer.blackberry.com/cascades/documentation/device_comm/push/exiting_after_processing_pus...

http://developer.blackberry.com/cascades/documentation/device_comm/push/handling_notifications_in_bl...

 

I highly recommend you take a look at the code samples in general.  They help explain the best practices you need to follow in your applicaiton.

 

Thanks,

 

Matt