If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
froboz
Posts: 17
Registered: ‎11-04-2010
My Device: Not Specified

Unable to load API features with <feature> tag

This seems like it should be about as basic as it gets, but I haven't had any luck.

 

I'm trying to get gyroscope data using the blackberry.sensors api.  I tried using one of the demo apps which make the following call:

 

blackberry.sensors.setOptions("devicecompass", { delay: 1000 });

 

But that just gives me an error: Uncaught TypeError: cannot call setOptions of undefined

 

I figured this must just mean that the sensors api wasn't loaded.  According to the docs I just need to add

 

<feature id="blackberry.sensors" />

 

to the config.xml file, but that doesn't seem to help.

 

Can anyone explain what I've done wrong? Here's my config.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.5" id="leveler" xml:lang="en">
<author href="http://www.blackberry.com/"
rim:copyright="Copyright 2012">Author</author>
<name>myapp</name>
<content src="index.html"/>

<description>
My Description
</description>

<icon src="icon-150.png"/>

<rim:splash src="splash-1280x768.png"/>
<rim:splash src="splash-768x1280.png"/>

<feature id="blackberry.app" />
<feature id="blackberry.sensors" />

</widget>

 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Unable to load API features with <feature> tag

It sounds like you might be missing the webworks.js file. Try adding the script src="local:///chrome/webworks.js" in the head of your HMTL document.

@erikjohnzon
erjohnson@blackberry.com
Please use plain text.
Developer
froboz
Posts: 17
Registered: ‎11-04-2010
My Device: Not Specified

Re: Unable to load API features with <feature> tag

I wondered if that might be the case, but the reference to webworks.js is already there.

 

The network inspector shows that the GET for webworks.js fails, but the console does indicate that webworks has loaded:

 

webworks.bb10 :: Initialization Finished (Make it so.)        ripple.js:475

 

I also have a listener on the webworksready event that does fire correctly, so webworks must be loading, mustn't it?

 

Yet, when anything tries to use a part of webworks, like the following I get errors. The following:

 
blackberry.event.addEventListener("devicecompass", compassCallback);
 
give me an error from ripple.js: 
 
Uncaught TypeError: Cannot read property 'callbacks' of undefined    ripple.js: 478
 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Unable to load API features with <feature> tag

If the GET for webworks.js fails then that isn't good. It sounds like an API loading issue in Ripple maybe? If your webworks.js can be loaded, then it will try and load the sensor API that you have requested. Is this what the GET fails on?

@erikjohnzon
erjohnson@blackberry.com
Please use plain text.
Developer
froboz
Posts: 17
Registered: ‎11-04-2010
My Device: Not Specified

Re: Unable to load API features with <feature> tag

The GET failure was definitely happening on the webworks.js file.

 

To try to eliminate any possible mistakes that I could have been making I uninstalled Ripple and reinstalled it with a fresh download.  Then I grabbed the BB10 WebWorks samples archive and loaded up the mediacards example.  Exactly the same problem - can't GET webworks.js.

 

Here's my console output when trying to load the example files which are being served by the internal Ripple webserver on localhost:9910

 

Failed to load resource local:///chrome/webworks.js
Ripple :: Environment Warming Up (Tea. Earl Gray. Hot.) ripple.js:475
webworks.bb10 :: Initialization Finished (Make it so.) ripple.js:475
eula response: true ripple.js:483
Failed to load resource local:///chrome/webworks.js
Viewport target-densitydpi is not supported. index.html (1):1
webworks.bb10 :: fired webworksready event! ripple.js:475
Uncaught TypeError: Cannot read property 'CAMERA_MODE_PHOTO' of undefined index.html:45
Failed to load resource local:///chrome/webworks.js
Viewport target-densitydpi is not supported. index.html (1):1
webworks.bb10 :: fired webworksready event! ripple.js:475
webworks.bb10 :: fired webworksready event! ripple.js:475
Uncaught TypeError: Cannot read property 'CAMERA_MODE_PHOTO' of undefined index.html:45

 

But I can package this just fine and deploy to the simulator without any issue. 

 

Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Unable to load API features with <feature> tag

Okay perfect. Could you just copy that description into an issue here: https://github.com/blackberry/Ripple-UI/issues
@erikjohnzon
erjohnson@blackberry.com
Please use plain text.
Developer
froboz
Posts: 17
Registered: ‎11-04-2010
My Device: Not Specified

Re: Unable to load API features with <feature> tag

This is submittted. Here's the link: https://github.com/blackberry/Ripple-UI/issues/651

 

To try to eliminate more variables I've disabled every other Chrome extension, the problem remains.

Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Unable to load API features with <feature> tag

Awesome, Bryan raised a couple good points this morning about how perhaps the device namespace is not implemented in Ripple yet. This could be part of the problem coupled with the local:///chrome not being found. Let's let the issue in the repo play out. It will get some attention for sure.

@erikjohnzon
erjohnson@blackberry.com
Please use plain text.