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
Contributor
Posts: 19
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: None
Accepted Solution

How to properly use "blackberry.app.exit"/"swipemenu" ?

Hello BB developers!

Can anyone show me how to use this feature? I'm using a physical PlayBook.

I tried using the following code:

 

<script src="scripts/bbui.js" type="text/JavaScript" charset="utf-8"></script>

 

<script>
function closeapp()
{
blackberry.app.exit()
}
</script>

<button onclick="closeapp()">This should close</button>

 

The config.xml have this feature:

<feature id="blackberry.app"/>

 

But when touching, nothing happens.

Do the bbui.js is necessary?

Or i'm using the wrong library/code?

Also how to call an action using the top swipe frame?

eg:

function someting()

{

use the topswipe

bla bla bla this happens

}

 

 

Thanks in advance for all the answers!

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

Re: How to properly use "blackberry.app.exit"/"swipemenu" ?

It sounds like your code is setup correctly.  However you never know if there's a bug in your JavaScript that is interfering.  In fact, if nothing is happening when you click on the button, then you may in fact have some badly-formatted JavaScript.

 

Suggest using remote web inspector to troubleshoot any potential runtime errors. Also, use jslint.com to check to make sure your JavaScript is valid.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Contributor
Posts: 19
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: None

Re: How to properly use "blackberry.app.exit"/"swipemenu" ?

Hello astanley and thanks for reply.

I made few changes and still can't use this feature.

I tried even creating a simple app for testing this feature but no sucess, here's the code:

 

<!DOCTYPE html>
<head>
<meta name="viewport" content="height=600,width=1024,user-scalable=no,target-densitydpi=device-dpi,initial-scale=1.0" />
<script src="bbui.js" type="text/javascript" charset="utf-8"></script>
<script>
function closeapp()
{
blackberry.app.exit()
}
</script>
</head>
<body>
<button onclick="closeapp()">Close</button>
</body>
</html>

 

 

On config.xml:

<feature id="blackberry.app" required="true" version="1.0.0"/>

Also used

<feature id="blackberry.app.event" required="true" version="1.0.0"/>

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

Re: How to properly use "blackberry.app.exit"/"swipemenu" ?

Ah I know what I missed.  You need to wait for the webworksready event.  

 

Make this change in your sample:

 

<script>
function closeapp() {
   blackberry.app.exit();
}

document.addEventListener("webworksready", function() {
   console.log("webworksready - can now use blackberry.* APIs");
});
</script>

 Here is the documentation on this requirement:

https://developer.blackberry.com/html5/documentation/getting_started_with_bb10_ww_sdk_2007056_11.htm...

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Contributor
Posts: 19
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: None

Re: How to properly use "blackberry.app.exit"/"swipemenu" ?

Hi!

Changed, packaged, installed & executed, still don't work.

 

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

Re: How to properly use "blackberry.app.exit"/"swipemenu" ?

One more time, I'm so used to seeing the webworks.js file reference, I didn't even notice it was missing from your sample.

 

You need to include the library that defines the blackberry.* APIs.  Here is how you do that:

 

 

<!DOCTYPE html>
<head>
<meta name="viewport" content="height=600,width=1024,user-scalable=no,target-densitydpi=device-dpi,initial-scale=1.0" />
<script type="text/javascript" src="local:///chrome/webworks.js"></script>
<script src="bbui.js" type="text/javascript" charset="utf-8"></script>
<script>
function closeapp()
{
blackberry.app.exit()
}
</script>
</head>
<body>
<button onclick="closeapp()">Close</button>
</body>
</html>

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Contributor
Posts: 19
Registered: ‎07-18-2012
My Device: Playbook
My Carrier: None

Re: How to properly use "blackberry.app.exit"/"swipemenu" ?

Sorry for the late reply, no free-time at all.

Thanks, this solved my problem!