02-23-2013 07:48 AM
Hi all,
i need to do push notification in blackberry 10 cascades,if i close the application means can't able to show my notification in the Blackberry Hub
here is the code
Button{
notification.body="hai notification testing "
notification.notify();
Notification {
id: notification
title: "Title"
}
}when the user closes the application means means,i need to show the notification in Blackberry Hub How to do this , can anyone send me some solutions to solve this.?
Thanks
02-23-2013 11:12 AM - edited 02-23-2013 11:13 AM
You should enable your application running in background then the pushed messages can invoke your application. You can register an invoke action of open to BB hub when the pushed messages invoked while your application is still running in background.When the message in the BB hub is opened, it will invoke your application to the foreground.
There is a good example in the sample application of PushCollector and you will find how to invoke customized messages to BB hub.
02-24-2013 11:46 PM
Hi
Thanks for your reply, i have downloaded the sample PushCollector as you said, how can i integrate it into my application, i have got Application id and PPG URL , how to implement this can you able to guide me
Thanks
02-25-2013 07:39 AM
Hi!
I am also trying to implement push notifications in my app. Please post if any one tried.!
Thanks.
- Raju
02-25-2013 08:35 AM - edited 02-25-2013 08:43 AM
If you have got an confirmed email which contains the Application Id and PPG URL (the first 3 digital of Application Id will be used in the PPG URL as cpxxx.pushapi.eval.blackberry.com(Development) or cpxxx.pushapi.na.blackberry.com(Production)).
If you want to implement your own Push initiator, you should download push sdk from here : http://developer.blackberry.com/services/push/?CPI
After you instlled your own push initiator, you can check off "Subscribe with Push Service SDK" and input the Push initiator URL.
Also need to check off "Launch App on new push"
The above steps is for the purpose of testing the push service is available on your device or not and it can also verify your push initiator.
After that, you can follow the logic in push collector to integrate into your application.
I think that the important thing is to know Channel and Sesssion. Channel is for registration and only do one time. Session is for listening the push message so that it should be established at the app launch.
Thanks
02-25-2013 08:47 AM
To add message into Hub, you can refer with the sample code in Push Collector :
// Create a notification for the push that will be added to the BlackBerry Hub
Notification *notification = new Notification(NOTIFICATION_PREFIX + QString::number(push.seqNum()),this);
notification->setTitle("Push Collector");
notification->setBody(QString("New %0 push received").arg(push.fileExtension()));
// Add an invoke request to the notification
// This invoke will contain the seqnum of the push.
// When the notification in the BlackBerry Hub is selected, this seqnum will be used to lookup the push in
// the database and display it
InvokeRequest invokeRequest;
invokeRequest.setTarget(INVOKE_TARGET_KEY_OPEN);
invokeRequest.setAction(BB_OPEN_INVOCATION_ACTION) ;
invokeRequest.setMimeType("text/plain");
invokeRequest.setData(QByteArray::number(push.seqN um()));
notification->setInvokeRequest(invokeRequest);
// Add the notification for the push to the BlackBerry Hub
// Calling this method will add a "splat" to the application icon, indicating that a new push has been received
notification->notify();
02-25-2013 09:38 AM
If you have any question about push service, you can post your question at this section :
I found my questions will always be responsed by BB advisor so quickly. ![]()
02-26-2013 01:32 AM
if you only want to semd a notification from your app running in the background into the hub
and then the user should be able to open your in-the-background running app from this notification,
you don't need full blown push services,
simply create a Notification, add InvokeRequest and notify() will send your Notification into HUB
and the Notification will have the OPEN Action directly jumping into your app
02-26-2013 01:46 AM
here's the code for notifications including invoke from hub
Notification n;
n.setTitle(tr("Your title"));
n.setBody(tr("your detailed description"));
n.setCategory("vibrate");
InvokeRequest request;
request.setTarget("org.xyz.yourapp.invoke");
request.setMimeType("application/vnd.yourapp");
n.setInvokeRequest(request);
n.notify();
and inside your bar descriptor you need
<!-- Have an invoke entry here for when a notification is clicked on in the BlackBerry Hub -->
<!-- This will cause the application to be opened -->
<invoke-target id="org.xyz.yourapp.invoke">
<type>APPLICATION</type>
<filter>
<action>bb.action.OPEN</action>
<mime-type>application/vnd.yourapp</mime-type>
</filter>
</invoke-target>
and dont forget to set permissions
<permission>run_when_backgrounded</permission> <permission>post_notification</permission>
02-28-2013 02:21 AM
HI ekke,
i need to show the notification when the application is closed