09-10-2012 10:20 AM - edited 09-10-2012 10:32 AM
Hi
I am developing BB 10 application and testing my app on Chrome Emulator & BB 10 Alpha Dev Simulator. At one step of my app I would like to add feature whereby a user can click the a link which will invoke browser argument.
I have declared following things in config.xml file
<rim:permissions> <rim:permit>access_shared</rim:permit> <rim:permit>read_geolocation</rim:permit> <rim:permit>use_camera</rim:permit> </rim:permissions> <content src="index.htm" rim:allowInvokeParams="true"/> <feature id="blackberry.invoke" /> <feature id="blackberry.ui.dialog"/> <access uri="*" />
In my javascript I am trying to invoke the browser by calling the following function
function visit_site()
{
console.log('BrowserInvoke');
blackberry.invoke.invoke({
target: "sys.browser",
uri: "http://www.abcd.com"
}, onInvokeSuccess, onInvokeError);
}
function onInvokeSuccess() {
console.log('Invocation successful!')
}
function onInvokeError(error) {
console.log("Invocation failed, error: " + error);
}When I run my .bar file in simulator it always goes into onInvokeError function.
I want it to load the the url in browser of device.
Apart from this also I would like to know that I have used flash object, but the app just gets closed flash object is called.
Thanks in advance.
Cheers
09-10-2012 10:32 AM - edited 09-10-2012 10:36 AM
Hi. I will add some response like requested here.
As far as I know the target command "sys.browser" isn't working for now since the browser on the BB10 at this time is the Air Browser version that needs to be called with another target command, but I might be wrong with this.
For BB10 also have a closer look to the invoke API documentation, there might be another way to open the browser using something like this:
blackberry.invoke.invoke({
uri: "http://www.blackberry.com"
}, onInvokeSuccess, onInvokeError);
09-11-2012 09:18 AM
Thanks LBP
Your post leads me to correct direction. As you said I have tried with invoke methods provided and I think the issue is because of confussion between air.browser & sys.browser.
However I have tried both the ways and even omitting it but still I get INVOKE_NO_TARGET_ERROR.
I guess this might be the issue with version which is not supporting air browser in invoke?
09-12-2012 04:28 AM
Hi mauzzamali,
this works for me. Let us know if it works for you too. Cheers!
// Method to follow links in BlackBerry Browser // ref: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/PlayBook-WebWorks-SDK-Invoking-B ... var _encodeURL = function(address) { console.log('[_encodeURL]', this, address); var encodedAddress = ""; // URL Encode all instances of ':' in the address encodedAddress = address.replace(/:/g, "%3A"); // Leave the first instance of ':' in its normal form encodedAddress = encodedAddress.replace(/%3A/, ":"); // Escape all instances of '&' in the address encodedAddress = encodedAddress.replace(/&/g, "\&"); return encodedAddress; }; var _openPlaybookBrowser = function(url){ try { // must use the crazy encode function due to bug var args = new blackberry.invoke.BrowserArguments( _encodeURL( url ) ); blackberry.invoke.invoke(blackberry.invoke.APP_BRO WSER, args); } catch(e) { alert("Exception: " + e); } };
09-12-2012 07:39 AM
For BB10 invoke checkout this-
https://github.com/blackberry/BB10-WebWorks-Sample
It shows how to make your app invokable and how to invoke other apps. You will find that App updated for the next release.