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

Posts: 19
Registered: ‎03-06-2014
My Device: blackberry z10 stl100-3
My Carrier: n/a
Accepted Solution

Trouble with getting any API's to work

I'm trying to ge the blackberry.app.exit() function to work.


I'm running webworks


This is my XML config file:

<?xml version='1.0' encoding='utf-8'?>
<widget id="Project1" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>WebWorks Application</name>
A sample Apache Cordova application that responds to the deviceready event.
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
<content src="index.html" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />


I basically copy pasted it from the hello world default one that the web tool makes. I tried it with and without

<feature id="blackberry.app">

according to:



you no longer need to declare the api in the xml file if you add it via webworks plugin add com.blackberry.app

command prior to running it.


this is my html header:


<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="js/condensejquery/themes/base/jquery-ui.min.css" />
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<!-- <script type="text/javascript" src="local:///chrome/webworks.js"></script> -->
<script type="text/javascript" src="js/condensejquery/jquery-ui.min.js"></script>
<script src="local:///cordova.js" type="text/javascript" ></script>

document.addEventListener("deviceready", function() {
console.log("webworksready - can now use blackberry.* APIs");
<title>Hello World</title>


According to webworks 2.0 it uses local:///cordova.js instead of local:///chrome/webworks.js, i've tried running it with both with no success. I added the document.addEventListener("deviceready", function() thingy in the header after all the .js source files because I read somewhere that it's mandatory for any webworks stuff.


The app works with the ripple emulator, when I click the button that exist the app I get the "this would exit the app if this was running on an actual bb device success message" but nothing happens when I try it on my blackberry z10 physical phone or emulated one on vmware.


Any help would be greatly appreciated! I'll include my full source code if need be, but the app runs without any errors in chrome so I don't thing it's poor javascript.


Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: Trouble with getting any API's to work

Why do you include 2 time cordova.js? Did you add webworks plugin add com.blackberry.app ?

BlackBerry Development Advisor
Posts: 758
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Trouble with getting any API's to work

So I just did a quick test using blackberry.app.exit() and it's working fine for me here.


I'd recommend trying this BfB Boilerplate sample - https://github.com/blackberry/BB10-WebWorks-Samples/tree/WebWorks-2.0/BfB-Boilerplate-bbUI.js-0.9x


Make sure to follow the build instructions at the bottom of the readme. The samples are definitely working, you should be able to simply download, add the plugins, and deploy in a matter of a couple minutes.

Posts: 19
Registered: ‎03-06-2014
My Device: blackberry z10 stl100-3
My Carrier: n/a

Re: Trouble with getting any API's to work

I got rid of the <script type="text/javascript" src="cordova.js"></script>

and kept the <script src="local:///cordova.js" type="text/javascript" ></script>

to get it working.


Thanks for the help