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
Highlighted
Developer
Posts: 123
Registered: ‎02-13-2012
My Device: Z10 LE
My Carrier: Mobistar
Accepted Solution

Receiving invocation

I have registered my Webworks 2.0 app for invocation like this in config.xml:

<rim:invoke-target id="com.bavoluysterborg.plottr">
    <type>APPLICATION</type>
    <filter>
      <action>bb.action.OPEN</action>
      <mime-type>*</mime-type>
      <property var="uris" value="file://"/>
      <property var="exts" value="plottr,csv"/>
      <icon>
        <image>icons/plottr-icon114.png</image>
      </icon>
    </filter>
</rim:invoke-target>

 When I try to open a .plottr or .csv file in the filemanager my app gets launched just fine, but I can't seem to catch the 'invoked' event to parse the request.

I have this code in the head of my index.html:

document.addEventListener('invoked', onInvoked);

var invoked = false;

function onInvoked(params) {
     invoked = true;
     console.log(params);
}

 The onInvoked function never gets fired...

Please click the like button if my post helped you! Thank you.
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Receiving invocation

Hi there,

 

I just tested a basic active text invocation with the following and my output was:

 

window.localStorage
Storage {}
1398804049469: "A"
1398804050057: "B"

Which, looking at the code (below), indicates that the onInvoked function is being called.

 

My process was to create a new webworks application using:

webworks create invoked

 

I also added the invoked plugin using:

webworks plugin add com.blackberry.invoked

 

I added the following invoke-target to my config.xml:

 

	<rim:invoke-target id="oros.invoked.test.view">
		<type>APPLICATION</type>
		<filter>
			<action>bb.action.VIEW</action>
			<mime-type>*</mime-type>
			<property var="uris" value="oros:"/>
		</filter>
		<invoke-target-pattern>      
			<pattern-value type="uri">oros:</pattern-value>    
		</invoke-target-pattern>
	</rim:invoke-target>

And my index.html looks as follows.

 

<!DOCTYPE html>
<html>
    <head>
        <title>Invoked Test</title>
    </head>

    <body>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript">
			/*global window, document */
			var wasInvoked = new Date().getTime();
			window.localStorage[wasInvoked] = 'A';

			window.addEventListener('load', function onLoad() {
				document.addEventListener('invoked', function onInvoked() {
					wasInvoked = new Date().getTime();
					window.localStorage[wasInvoked] = 'B';
				}, false);
			}, false);
        </script>
    </body>
</html>

I ran in debug mode using:

webworks run

 

And then connected Web Inspector and checked window.localStorage to see that both A and were logged (in that sequence), indicating the invoked function was called.

 

 

Finally, my invocation launcher (i.e. external web page) that I browsed to / clicked the link on was as follows.

 

<!DOCTYPE html>
<html>
	<head>
		<title>Invoked</title>
	</head>
	<body>
		<a href="oros://www.someurl.com">Some URL</a>
	</body>
</html>

 

I'll try adapting this though to more closely reflect your use-case.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Developer
Posts: 123
Registered: ‎02-13-2012
My Device: Z10 LE
My Carrier: Mobistar

Re: Receiving invocation

Ok, I've figured it out, I had to set the action to bb.action.VIEW in stead of bb.action.OPEN.

One more question, I now enabled my app to become the default app for files ending in the .plottr extension, is it possible to assign a custom icon to those files?

Please click the like button if my post helped you! Thank you.
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Receiving invocation

Hmm, that's quite peculiar that it works with VIEW and not OPEN. I've reached out to our dev teams to see if they can shine any light on that behaviour.

In another thread, there's a developer that is also having issues with the invoked function triggering. Though they are using Push Services (which leverage bb.action.OPEN). Whether this is an issue with OPEN inherently is what I'm hoping to determine.

In the meantime, glad that VIEW is working for you.

When you say "assign a custom icon", do you mean on the filesystem? So that when you browse to that file, it comes up with that icon?

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Developer
Posts: 123
Registered: ‎02-13-2012
My Device: Z10 LE
My Carrier: Mobistar

Re: Receiving invocation


oros wrote:
When you say "assign a custom icon", do you mean on the filesystem? So that when you browse to that file, it comes up with that icon?

That's exactly what I mean, I couldn't find anything about it in the docs.

Please click the like button if my post helped you! Thank you.
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Receiving invocation

Hi there, unfortunately there aren't any APIs to customize the icon for file extensions handled by your application; though it would be ideal to have the default application (as selected by the user) to be able to specify an icon. I'd recommend logging a feature request via JIRA for this:
https://www.blackberry.com/jira/secure/Dashboard.jspa

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 31
Registered: ‎04-21-2011
My Device: Playbook
My Carrier: N/A

Re: Receiving invocation

I've filed an issue for this after encountering the same problem myself today:

 

https://www.blackberry.com/jira/browse/BBTEN-2460

 

I guess I am left wondering what the role of the icon element in the invoke-target directive is, if it isn't to indicate what app will open a file when I tap on it in the Hub and File Manager:

 

https://developer.blackberry.com/html5/documentation/v2_1/receiving_invocation.html

 

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Receiving invocation

I believe that would be for when your application shows up in an invocation list. For example, when sharing an image, you get a listing of targets that it can be shared with, which includes name/icon.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Developer
Posts: 123
Registered: ‎02-13-2012
My Device: Z10 LE
My Carrier: Mobistar

Re: Receiving invocation

Indeed, I think it's also used when there are multiple apps capable of opening a certain file extension and you have to select a default app.
Please click the like button if my post helped you! Thank you.
Developer
Posts: 39
Registered: ‎01-07-2009
My Device: Not Specified

Re: Receiving invocation

I too am seeing this issue now.

 

I had a WebWorks 1.x app that received invocation just fine.  I upgraded to WebWorks 2.x (now 2.2) and my app gets invoked, by my invocation handler (onInvoked function, just like this example) is NEVER called.

 

my document.addEventListener('invoked',onInvoked);   does appear to be called to set up the listener.

 

I tried changing my config from bb.action.OPEN to bb.action.VIEW, but that didn't help or make any difference.

 

Has anyone else seen/worked around this?