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
Regular Contributor
Sonic63
Posts: 81
Registered: ‎10-21-2012
My Device: playbook, storm, curve

BB10 sys.browser webworks help.

I am using the sample code off the BB10 webworks developer site and I can't get the Invoke Browser button to do anything in the simulator.  The page loads fine but the button doesn't seem to work.

 

Here is the config file.

====

 

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="2.0.0.0" id="sampleapp">

<author href="http://www.example.com/"
rim:copyright="Copyright 1998-2012 My Corp">My Corp</author>

<name>Sample application</name>

<description>
A sample application to demonstrate some features.
</description>

<rim:smileytongue:ermissions>
<rim:smileytongue:ermit>access_shared</rim:smileytongue:ermit>
<rim:smileytongue:ermit>access_location_services</rim:smileytongue:ermit>
<rim:smileytongue:ermit>use_camera</rim:smileytongue:ermit>
</rim:smileytongue:ermissions>

<icon src="icon5.png"/>



<content src="index.html" rim:allowInvokeParams="true"/>

<feature id="blackberry.ui.dialog"/>

<feature id="blackberry.app.orientation">
<param name="mode" value="portrait" />
</feature>

<feature id="blackberry.app">
<param name="backgroundColor" value="0xFFFF0000" />
</feature>

<access uri="http://www.rim.com" subdomains="true">
<feature id="blackberry.app" required="true" version="1.0.0"/>
<feature id="blackberry.invoke" required="true" version="1.0.0"/>
</access>

<license href="http://www.example.com/"/>

</widget>

 

======

 

Here is the HTML file.

 

=========

 

<html>
<body>
<p>
<b>blackberry.app</b>
<br/>
<input type="text" id="textAppName"/>
<br>
<input type="text" id="textAppVersion"/>
</p>
<p>
<b>Test invoke with PPS</b>
<br/>
<input type="button" onclick="window.invoke?window.invoke():
alert('WebWorks is not ready yet');" value="Invoke Browser"/>
<input type="textarea" id="textbrowser" value="http://www.rim.com"/>
</p>
<script src="local:///chrome/webworks.js" type="text/javascript"></script>
<script>
function invoke() {
blackberry.invoke.invoke({target: "sys.browser",
uri: document.getElementById('textbrowser').value},
onInvokeSuccess, onInvokeError);
}
window.addEventListener("load", function(e) {
document.addEventListener("webworksready", function(e) {
document.getElementById('textAppName').value = blackberry.app.name;
document.getElementById('textAppVersion').value = blackberry.app.version;
window.invoke = invoke;
}, false);
}, false);

function onInvokeError()
{
alert("Error");
}

function onInvokeSuccess()
{
alert("Success");
}
</script>
</body>
</html>

BlackBerry Development Advisor
cdelcol
Posts: 37
Registered: ‎01-08-2010
My Device: Various

Re: BB10 sys.browser webworks help.

It looks like your config.xml has issues...

 

<access uri="http://www.rim.com" subdomains="true">
<feature id="blackberry.app" required="true" version="1.0.0"/>
<feature id="blackberry.invoke" required="true" version="1.0.0"/>
</access>

 

This means that you have access to blackberry.invoke on a page located at www.rim.com. You want to move those <feature> elements outside of the access elements like you have for blackberry.app.orientation. I suspect that will fix your issue.

 

Where is the sample that you based this off of? Was it a straight copy, or did you make this change yourself?

Regular Contributor
Sonic63
Posts: 81
Registered: ‎10-21-2012
My Device: playbook, storm, curve

Re: BB10 sys.browser webworks help.

[ Edited ]

Thanks for the reply.

 

 

Yes I changed that line from somedomain to rim.com   <access uri="http://www.somedomain.com"subdomains="true">

 

I also changed <icon src="icons/icon-150.png"/> to <icon src="icon5.png"/>

 

Here is the URL for the config file

 

https://developer.blackberry.com/html5/documentation/code_sample_creating_a_bb_widget_config_documen...

Regular Contributor
Sonic63
Posts: 81
Registered: ‎10-21-2012
My Device: playbook, storm, curve

Re: BB10 sys.browser webworks help.

[ Edited ]

Made the changes and it still does not work in the simulator.

 

In ripple I get this: 


Requested to invoke external application with the following arguments:
target = sys.browser
uri = http://www.rim.com