Webworks lesson learnt today: banner notifications
One of the reasons I wanted to start this blog was to have the possibility of teaching others a few things which I learn the hard way. Sometimes I have to bang my head on the wall for a few hours, until I finally find out a solution (usually, a simple one). In order to help others avoiding that, I want to share the pitfalls I encounter along the way, and the quick and easy way to solve them.
Today, this was the one:
How to the display a banner notification in BB smartphones?
Using WebWorks, you can call the blackberry.app.showBannerIndicator() function to easily display a notification on the home screen banner bar.
This function can take 1 or 2 arguments: 1, the notification icon and 2, a number to go with the icon (optional).
It’s really simple, but for some reason I was getting exceptions thrown all the time. After a lot of digging in forums, here are the 2 problems you might face, which as of this version of WebWorks (2.1.3) will not allow it to work:
- The icon must exist, and its dimensions must be between 10×10 and 32×32
- The icon path must be something like “images/icon.png”, unlike the set homescreen icon function that takes a “local:///images/icon.png” argument.



Is there away to cancel the notification once displayed…
For exampe user has edited a form and application went background.
Make a notifcation savign “Please save your data before turning off the device”
But then the user doesnt read the nofication and goes back in to the application and saves it..
Can this be done + Nice blog
Hi Liam.
Yes you can clear all the notifications manually. There’s a function to remove the banner indicator, and the notification extension also has a function to cancel the notifications (LED, sound, etc).
Thanks
I like what you’re doing, really noble.
For the benefit of others who might be reading this blog to solve a similar problem you should also remember to include in your config.xml
I have added the openBISPushListener() to my app and when i execute a push from the push server, the application wakes up the designated page but i have no banner indicator to show that the push has been received.
At this time, what I want to know is, where to trigger blackberry.app.showBannerIndicator() function.
Hi Oladele,
From what I understood, I think the showBannerIndicator button would go into the page called on wakeup by the openBISPushListener.
All the best,
Nuno
Liam, sir, I would shake your hand but geography is still our reality, so kindly accept a thank you instead.
All the pieces of my app are in place… Now to go make some real money..