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
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

display push notification in BB 10 Cascades

 

In my app, I need to show push notification. for that i am using Two Qml files

one Qml For Displaying the "Push Notification" and other for the "App Home Screen".

I have two options, as follows

 

case-1 : Open the App Home page /Screen directly, if no push notification is received already.

 

case-2 : Open the Push Notification, if notification is received already

 

For the that , I need to check exactly like

 

switch (isPushReceivedAlready()){
case 1:

    qmlDocument = "asset:///push.qml";
    qDebug() << "Push received Push screen is set as Home Screen";
    break;
case 2:

    qmlDocument = "asset:///main.qml";
    qDebug() << "Push not received, so main screen is set as Home Screen";
    break;
 }
 QmlDocument *qml = QmlDocument::create(qmlDocument).parent(this);

 // Create root object for the UI
 AbstractPane *root = qml->createRootObject<AbstractPane>();

 // Set created root object as the application scene
 app->setScene(root);

 

 

But there is no like " isPushReceivedAlready() " function. my App need to sense if any notification are received and display screen accordingly.

please help,

Thanks !!!

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: display push notification in BB 10 Cascades

Hi there!

 

Take a look at my SimplePushClient sample app:

https://github.com/blackberry/Cascades-Community-Samples/tree/master/SimplePushClient

 

This app will behave differently depending on when a push is received (if the app is open vs closed). It also caches push messages and integrates with the Active Frames.

Garett
@garettBeuk
--
Goodbye everybody!
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: display push notification in BB 10 Cascades

But here i didn't find push initiator URL to interact with the server...I am not sure that works...

Thanks...

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: display push notification in BB 10 Cascades

The push initiator is created by you, so you would have to expose its URL publicly if you require registration

Garett
@garettBeuk
--
Goodbye everybody!
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: display push notification in BB 10 Cascades

may be what you are saying is right...but i have added "PushCollector" from GitHub...now reverting all the code makes not sence...Is there any  similar way to that using  PushCollector Example 

 

Thanks,

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: display push notification in BB 10 Cascades

There's an option in PushCollector to not register with your server, doing that will allow you to register with the PPG without needing your Push Initiator to be exposed.

Garett
@garettBeuk
--
Goodbye everybody!
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: display push notification in BB 10 Cascades

ya i am doing that...here my question is not with Push initiator. It is switching between the qml's when no push is received and push is received before opening the App

Retired
Posts: 2,559
Registered: ‎10-16-2009
My Device: BlackBerry Z10
My Carrier: Bell

Re: display push notification in BB 10 Cascades

Well, like I said, my sample does that. You don't need to discard all the code in your app, but reference my sample to see how this can be done.

 

The InvokeManager will let you check how your app was launced, but you'll also need to track if the app has ever been full screened to know if it was already running when a push arrived:

https://developer.blackberry.com/native/reference/cascades/bb__system__invokemanager.html?f=invokema...

Garett
@garettBeuk
--
Goodbye everybody!
New Developer
Posts: 104
Registered: ‎09-25-2013
My Device: BB 10
My Carrier: BB 10

Re: display push notification in BB 10 Cascades

I am connecting to Invoke Manage like in my App,

 

 QmlDocument *qml = QmlDocument::create("asset:///main.qml");
    qml->setContextProperty("_pushAPIHandler", this);
    AbstractPane *root = qml->createRootObject<AbstractPane>();
    Application::instance()->setScene(root);

    // populate the model with the pushes that are stored in the database
    m_model->insertList(m_pushNotificationService.pushes());

    // 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&)));

 how this helps me to swithing...

Thanks,