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
Contributor
mauzzamali
Posts: 16
Registered: ‎03-25-2012
My Device: Blackbery Playbook
My Carrier: Aircel

Facing difficulty while invoking browser argument in BB 10 application

[ Edited ]

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

Please use plain text.
Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: Facing difficulty while invoking browser argument in BB 10 application

[ Edited ]

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);

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Please use plain text.
Contributor
mauzzamali
Posts: 16
Registered: ‎03-25-2012
My Device: Blackbery Playbook
My Carrier: Aircel

Re: Facing difficulty while invoking browser argument in BB 10 application

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?

 

 

 

Please use plain text.
Developer
billbsb
Posts: 143
Registered: ‎03-25-2011
My Device: Playbook, Z10 L.E.
My Carrier: Vodafone NL

Re: Facing difficulty while invoking browser argument in BB 10 application

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_BROWSER, args);
		 } catch(e) {
		 	alert("Exception: " + e);
		 }
	};
Cheers!
Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: Facing difficulty while invoking browser argument in BB 10 application

For BB10 invoke checkout this-

 

https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/invoke

 

It shows how to make your app invokable and how to invoke other apps. You will find that App updated for the next release.

 

 

@nukulb
Please use plain text.