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

Native Development

Reply
Contributor
maheshkumar1990
Posts: 44
Registered: ‎01-07-2013
My Device: 9300
My Carrier: blackberry

Push Notification in Blackberry Hub

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

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: Push Notification in Blackberry Hub

[ Edited ]

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. 




p(^_^)q
Good good study, day day up
Please use plain text.
Contributor
maheshkumar1990
Posts: 44
Registered: ‎01-07-2013
My Device: 9300
My Carrier: blackberry

Re: Push Notification in Blackberry Hub

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

Please use plain text.
Developer
raju504
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: IDEA

Re: Push Notification in Blackberry Hub

Hi!

 

     I am also trying to implement push notifications in my app. Please post if any one tried.!

 

Thanks.

- Raju

- Raju
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: Push Notification in Blackberry Hub

[ Edited ]

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/?CPID=PUSHAPI00

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.

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

 

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




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: Push Notification in Blackberry Hub

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.seqNum()));
    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();

 




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: Push Notification in Blackberry Hub

If you have any question about push service, you can post your question at this section :

 

http://supportforums.blackberry.com/t5/BlackBerry-Push-Development/bd-p/Applications_using_Push_Tech...

 

I found my questions will always be responsed by BB advisor so quickly. :Phone:




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
ekke
Posts: 1,428
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Push Notification in Blackberry Hub

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

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
ekke
Posts: 1,428
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Push Notification in Blackberry Hub

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>

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Contributor
maheshkumar1990
Posts: 44
Registered: ‎01-07-2013
My Device: 9300
My Carrier: blackberry

Re: Push Notification in Blackberry Hub

HI ekke,

              i need to show the notification when the application is closed

Please use plain text.