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
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Ok, I managed to get the push messages on the app! The alert triggered after a reinstall :smileyhappy:

 

But I can't seem to get the notifications while the app is open. Is it possible to show the notification on the device desktop, like the other native apps?

 

Thanks again!

Please use plain text.
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Sorry, I can't seem to get the notifications while the app is CLOSED
Please use plain text.
Retired
marco_dicesare
Posts: 76
Registered: ‎08-08-2012
My Device: BlackBerry Z10

Re: Push notifications in Webworks app

That good news that you've been able to make progress.

 

I see in the sample code you posted beofre that you are specifying index.html as your wakeUpPage. So when a push comes in and your application is closed the following page will be loaded.

var wakeUpPage = "index.html";

 

 Can you confirm that the body onload in your index.html calls the blackberry.push.openBISPushListener() function?

 

Also from the Push API reference it says you must specify the rim:allowInvokeParams="true" in your config.xml

https://developer.blackberry.com/html5/apis/blackberry.push.html#.openBISPushListener

 

For example,

 

<content src="index.html" rim:allowInvokeParams="true" />

 You may also want to add the following feature to your config.xml

<feature id="blackberry.invoke" required="true" version="1.0.0.0"/>

 

Please use plain text.
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Ok, so I did confirm the blackberry.push.openBISPushListener() is called on the body load of index.html and added those configurations to the config.xml file (i was missing the feature blackberry.invoke).

 

When I have the application open, the notifications arrive perfectly, but when I close the app or when I switch to another task (using the BB key) the notifications cease.

 

Do you know if this is possible to do? I mean, how does the push notification know where the index.html page is if the app is closed?

Please use plain text.
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Also, if it helps, if I close the app and open it again, it also stops receiving pushes...
Please use plain text.
Retired
marco_dicesare
Posts: 76
Registered: ‎08-08-2012
My Device: BlackBerry Z10

Re: Push notifications in Webworks app

The push APIs know to launch your app when a push comes in. It uses an alternate entry point into your app. That's why you specificy a wake up page option when you call the openBISPushListener(...) API. When your app is started it is told to open the page specified by the wake up page parameter. That wake up page should make a call to openBISPushListener(...) in the body onload.

And yes, push messages can be received while the app is in the foreground, background(minimized) or closed.

You have to ensure that every page in your app opens the push listener in it's body onload.
Please use plain text.
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Ok, understood, thanks :smileywink:

 

My app only has the index.html page, I'm using jquery mobile to change the display, so my only page has the body onload calling the openBISPushListener... what else can I check?

Please use plain text.
Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer

Re: Push notifications in Webworks app

[ Edited ]

I have been having the exact same issue and fixed it by moving openBISPushListener out of the onload event as follows:

Change
 

<script type="text/javascript" charset="utf-8">
		function onLoad() {
			openBISPushListener();
		}
</script>

...
<body onload="onLoad()">

 to 

<script type="text/javascript" charset="utf-8">
	openBISPushListener();
</script>

It seems that the onLoad event gets fired too late so that the push listener is not declared in time to catch the notification, thus causing an exception. I understand it is better practice to defer loading of javascript but unfortunetly this is the only solution I can think of at present . . .

 

Please use plain text.
Contributor
sergiop
Posts: 23
Registered: ‎04-13-2012
My Device: Curve 9300 OS6

Re: Push notifications in Webworks app

Thanks for the tip, Ryanthegiantlion, but I already tried that and it didn't work...

Please use plain text.
Contributor
Ryanthegiantlion
Posts: 17
Registered: ‎08-23-2012
My Device: developer

Re: Push notifications in Webworks app

Have you given up on this? I noticed your original post was from quite a few weeks ago. . . 

It did take some time but I eventually had some success using Pushwoosh.

Please use plain text.