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

Web and WebWorks Development

Reply
Trusted Contributor
Posts: 100
Registered: ‎01-13-2012
My Device: Simulator - 9800
My Carrier: Simulator

Notification Support

Does webworks support a notification icon alert? One that pops up on the home screen to alert the user of new information. And is running a background application also supported?

Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Notification Support

Yes, for the Smartphone SDK, you can use the Notification API (currently a community API candidate):

 

https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Smartphone/notification

 

Starting with PlayBook Tablet OS 2.0, you can use HTML5 Web Notification

 

Example:

 

var imgPath, title, message;
	
imgPath = "http://icons.iconarchive.com/icons/martin-berube/animal/32/monkey-icon.png";
title = "Web Notification";
message = "Sent from the Kitchen Sink app.";

webkitNotifications.createNotification(imgPath, title, message).show();

 Also, see http://slides.html5rocks.com/#notifications-api

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Notification Support

Does the icon have to be on the web? or can be it be based within the bar file?


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Notification Support


astanley wrote:
...

 

Starting with PlayBook Tablet OS 2.0, you can use HTML5 Web Notification

 

Example:

 

var imgPath, title, message;
	
imgPath = "http://icons.iconarchive.com/icons/martin-berube/animal/32/monkey-icon.png";
title = "Web Notification";
message = "Sent from the Kitchen Sink app.";

webkitNotifications.createNotification(imgPath, title, message).show();

 Also, see http://slides.html5rocks.com/#notifications-api


I tried it last days on PlayBook and BB10 and bot do not support the remote or local image like shown in the example. Also the KitchenSink example doesn't show that image for the notification.

 

The next is the missing support for events onclick|onshow|onclose|onerror since they seem to not completely work on both, PB and BB10 and last but not least when you call the close() handler an already shown notification won't be removed from the task bar.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Notification Support

did you have to invoke anything to get this to work?

 

I am getting a bunch of errors *Type Error* and it is not working on my device (I think webkit notifications is not enabled).


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Notification Support

I asume the WebView a WebWorks app is running within is based on webkit engine and so the window.webkitNotifications should be available by default!

 

What about the Web Inspector, when you let it show output the webkitNotifications object like this:

 

console.log(window.webkitNotifications);

Should output the object to the console and you should be able to inspect it.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Notification Support

BTW: you need to request for the permission to show a notification:

 

window.webkitNotifications.requestPermission(function() {/* TODO */});

Or check if you already have permission:

 

window.webkitNotifications.checkPermission()

For some more informations and examples have a closer look to the HTML5Rocks website for webkitNotifications.

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Notification Support


LBP wrote:

I asume the WebView a WebWorks app is running within is based on webkit engine and so the window.webkitNotifications should be available by default!

 

What about the Web Inspector, when you let it show output the webkitNotifications object like this:

 

console.log(window.webkitNotifications);

Should output the object to the console and you should be able to inspect it.




 

I webinspectored it.. tbh wasnt too sure what i was doing but i didnt see any errors related to the type errors im getting.


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Notification Support


ignites wrote:
...

 

I webinspectored it.. tbh wasnt too sure what i was doing but i didnt see any errors related to the type errors im getting.


Mhhhh. Mysterious. What are your type errors about. Can you put some messages in here to check little bit more?


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Posts: 466
Registered: ‎04-11-2012
My Device: Bold 9900
My Carrier: Rogers

Re: Notification Support

I am using the png file from App World icon set ... not sure if that is the 'type' error.


Developer for easyDial for BlackBerry Bold & inLink for BlackBerry PlayBook
Find me online via twitter, or on the techfruits.com webpage. Please hit the like button below if what I said helped!