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
Developer
Posts: 58
Registered: ‎06-28-2013
My Device: Z10
Accepted Solution

BlackBerry Notifications hub example not working properly

I tried creating a simple notifications webworks app which invokes a callback when an item is selected in the notifications hub. That is, I create a notification without a target so that when it's opened my app will get a notification as long as I have a listener attached to the 'invoked' event. This is all described here. Even though the notification does appear in the hub opening it didn't invoke my callback. 

 

I was pretty sure I was doing something wrong so I checked out the BB10 webworks notification example from here and deployed it. This didn't work either... The only change I had to make was to replace the inclusion of the webworks library (<script type="text/javascript"src="./js/webworks-1.0.2.9.js"></script>) to the newest one (1.0.4) as the app wouldn't run otherwise.

 

Is this a bug? Or am I doing something completely wrong?

Retired
Posts: 71
Registered: ‎09-19-2012
My Device: No sleep til BlackBerry 10

Re: BlackBerry Notifications hub example not working properly

When you open the notification in the hub, you're also tapping the Open button in the Action Bar that appears at the bottom of the screen?

------------------------------
@grahamzibar
-_- zZZ
Developer
Posts: 58
Registered: ‎06-28-2013
My Device: Z10

Re: BlackBerry Notifications hub example not working properly

[ Edited ]

It does give me an Open button but tapping just makes the notification go away. My JS handler doesn't get called.

Developer
Posts: 58
Registered: ‎06-28-2013
My Device: Z10

Re: BlackBerry Notifications hub example not working properly

[ Edited ]

I tried out this (from the developer website)

// Create a notification with invocation information
  // and use invoked event to determine and do something for that notification
  var title = "A notification for something";
  var options = {
      targetAction : "bb.action.DoSomethingForNotification", // If no target is specified, it will invoke the current application
      payloadURI : "some link"
  }

  // Create the notification
  new Notification(title, options);

  // Register to listen to invoked event
  blackberry.event.addEventListener("invoked", onInvoked);

  // Handle invoked event
  function onInvoked(onInvokedInfo) {
	     // Do something if the action is "BB.action.DoSomethingForNotification"
	     if(onInvokedInfo.action == "BB.action.DoSomethingForNotification") {
	         doSomething(onInvokedInfo.uri); // onInvokedInfo.uri is "some link"
      }
  }

 

 

Developer
Posts: 58
Registered: ‎06-28-2013
My Device: Z10

Re: BlackBerry Notifications hub example not working properly

If anyone comes across this, the solution was to add the invoke setting in config.xml 

<rim:invoke-target id="notifications">
    <type>APPLICATION</type>
		<filter>
			<action>bb.action.OPEN</action>
			<mime-type>text/plain</mime-type>
		</filter>
	</rim:invoke-target>

 

New Contributor
Posts: 5
Registered: ‎06-19-2013
My Device: STL100-1

Re: BlackBerry Notifications hub example not working properly

 

@ config.xml

 

<feature id="blackberry.invoke" />
<feature id="blackberry.invoke.card" />

 

<rim:invoke-target id="yourApicalitionName">
<type>APPLICATION</type>
<filter>
<action>bb.action.OPEN</action>
<mime-type>text/html</mime-type>
</filter>
</rim:invoke-target>

 

<rim: permissions>
<rim: permit>post_notification</rim: permit>

</rim: permissions>

 

 

@index

<script src="js/lib/bbui.js" type="text/javascript"></script>
<script src="js/lib/notify.js" type="text/javascript"></script>

 

 

setTimeout(function(){
var title = "A notification will invoke browser";
var options = {
//target: "com.rim.bb.app.yourApicalitionName",
body : "Some details",
targetAction : "bb.action.OPEN",
payloadURI : "local:///main.html"

}

var n = new Notification(title, options);}, 1000 * 20);    //20secs after open the apps - notification will occur

 

 

Hopefully this could work