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
New Contributor
Posts: 4
Registered: ‎06-29-2011
My Device: Many

Can I invoke the BB Browser from a remote JavaScript file?

Hello all,

 

I have a webworks app that needs to invoke the BB browser with a certain URL. 

 

When I have the JavaScript file and HTML page embedded in my webworks application on the device, the browser is invoked correctly. 

 

However, when I have the same HTML and JS file served from a remote server, and my web works application's "content src" pointed to the remote URL of the HTML page, the browser is not invoked when my JS executes. 

When trying to invoke the browser, it returns the error 'blackberry.invoke is undefined.'

 

Here is my javascript function:

 

 

function displayLink(link){

if(typeof blackberry !== 'undefined'){

alert("Trying to launch BB Browser");

try{

alert("invoke: "+blackberry.invoke);

var args = new blackberry.invoke.BrowserArguments(link);

 blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);

}catch(e){

alert(e.message);

}

}else{

window.location=link;

}

 

 

My config XML requires blackberry.identity, blackberry.invoke, blackberry.invoke.BrowserArguments, and blackberry.invoke.JavaArguments. 

 

Is it possible to invoke native BB apps from a remote JS file in a WebWorks application?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Can I invoke the BB Browser from a remote JavaScript file?

If you are bringing in a remote page that requires access to APIs you need to declare them for that origin.  If your page is coming from http://www.foo.com and you want to provide access to say blackberry.system your config should look like the following

 

<access uri="http://www.foo.com" subdomains="true">
  <feature id="blackberry.system" />
</access>

 This is done to ensure that when you bring in content from outside domains you need to explicitly declare which APIs they can access.  This ensures that outside content is controlled on what can be executed.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 4
Registered: ‎06-29-2011
My Device: Many

Re: Can I invoke the BB Browser from a remote JavaScript file?

Thank you for your quick reply, that is exactly what I needed!