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
Developer
Concession
Posts: 31
Registered: ‎03-06-2011
My Device: Not Specified

Invoke.browser Issues - Playbook

[ Edited ]

I intend to use the invoke browser API to to open websites that are external to my webworks application, and are not produced by me.

 

 

I've been having two problems with this API, the first may just be a difference between what I would like it to be, and what it is.

 

I ran into these issues using simulator version 0.93.

 


1) Right now, the API works great for my application when the browser is closed.
I can touch a link in my application which calls the invoke.browser API, and then proceeds to zoom out from my app, and open the browser with the web page I intended.

Problem is, if the browser is already open, this doesn't do what I would like it to. In the simulator  if I click on the same link, it zooms out from my application and zooms in onto the browser, but then does nothing, and just displays the webpage that was previously open.

Ideally, I would like the browser to then proceed to open the link I gave the invoke browser API in a new tab if the browser is already open.

 

2) It seems that I cannot use the invoke browser API to open any kind of URL that contains an "=" sign.

For example, I want to have a link in my app which will link to a search on wolfram alpha.

on wolfram alpha the general URL looks like:
www.wolframalpha.com/input/?i=Whatever it is you are seaching for

So when I pass the invoke browser a URL of
www.wolframalpha.com/input/?i=RIM

 

This would nomally open up a page on wolfram alpha with the results RIM which would give

information on the company Research in Motion.

 

the invoke.browser api only gives the browser:

www.wolframalpha.com/input/?i

which effectively cuts out every character of the URL after the "=" sign. Which is
not the website I wish to open.





These are problems I have run into while trying to finish off my app. If you know any solutions, or are even able to replicate them, it would be great.

 

 

EDIT:

The permissions I have in my XML file are:

    <feature id="blackberry.app" required="true" version="1.0.0" />
    <feature id="blackberry.invoke" required="true" version="1.0.0"/>
    <feature id="blackberry.invoke.BrowserArguments" required="true" version="1.0.0"/>
    <feature id="blackberry.identity" required="true" version="1.0.0"/>
    <feature id="blackberry.ui.dialog" required="true" version="1.0.0"/>

 

 

 

and the javascript function I've been using to open the browser is of the form:

 

function blackberrybrowser(page){


 var args = new blackberry.invoke.BrowserArguments(page);
 blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);

};

 

where page is a string containing the URL I wish to open. eg, 'www.wolframalpha.com/input/?i=RIM'

Please use plain text.
Contributor
martihs
Posts: 10
Registered: ‎03-03-2011
My Device: Z10 / Dev Alpha C / PlayBook
My Carrier: Vodafone

Re: Invoke.browser Issues - Playbook

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Invoke.browser Issues - Playbook

I'm curious.. Have you checked the tabs in the browser?  I'm wondering if it is opening a tab in the browser but not bringing it to the front.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
Concession
Posts: 31
Registered: ‎03-06-2011
My Device: Not Specified

Re: Invoke.browser Issues - Playbook

Yeah, I just tested it again, It doesn't make any new tabs.

 

It is really strange, becuase it does exactly the same transition between my app, and the browser, the only difference is if the browser is already open, it doesnt load the page, and the address bar remains untouched.

Please use plain text.
New Contributor
armandopcm
Posts: 4
Registered: ‎05-27-2011
My Device: PlayBook
My Carrier: Telcel

Re: Invoke.browser Issues - Playbook

Hello,

I just posted a solution to this problem in another post, here is the code you need:

 

CODE:

function followLink(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, "\&");
	
	if (typeof blackberry !== 'undefined') {
		try{
			// If I am a BlackBerry device, invoke native browser
			var args = new blackberry.invoke.BrowserArguments(encodedAddress);
			blackberry.invoke.invoke(blackberry.invoke.APP_BROWSER, args);
		} catch(e) {
 			alert("Sorry, there was a problem invoking the browser");
 		}
	} else {
		// If I am not a BlackBerry device, open link in current browser
		window.location = encodedAddress; 
	}
}

 

 

If you want the explanation, you can check out the other post:

http://supportforums.blackberry.com/t5/Web-Development/PlayBook-WebWorks-SDK-Invoking-Browser-Doesn-...

 

Cheers!

AJ

Please use plain text.
Developer
Concession
Posts: 31
Registered: ‎03-06-2011
My Device: Not Specified

Re: Invoke.browser Issues - Playbook

Neat.

This problem actually was fixed in the newest playbook sdk. None of the problems mentioned above exist anymore.

It's a good thing because I use this a good bit in my app.
Please use plain text.
New Contributor
armandopcm
Posts: 4
Registered: ‎05-27-2011
My Device: PlayBook
My Carrier: Telcel

Re: Invoke.browser Issues - Playbook

It would seem that the problem was fixed, (it works in some basic cases) but if you try a more complex url (sharing for example) you will notice that it does not work. One of the issues seems to be having more than one colon ':' in the url like when you have mutliple addresses inside the url you want to invoke.

 

Cheers!

AJ

Please use plain text.
New Contributor
waleswizard
Posts: 5
Registered: ‎06-28-2011
My Device: Playbook
My Carrier: Sonic

Re: Invoke.browser Issues - Playbook

any one please help me, i  success implement blackberry.invoke.BrowserArguments, but there is some bug after i open new window browser my webwork apps become freeze cannot touch any thing :smileysad:

Please use plain text.
New Contributor
armandopcm
Posts: 4
Registered: ‎05-27-2011
My Device: PlayBook
My Carrier: Telcel

Re: Invoke.browser Issues - Playbook

Hello waleswizard,

Can you be more specific about your problem?

 

Does it only occur when you invoke a browser window and switch back to your app?

Does it also occur when you switch to any other app and come back to your own?

Please use plain text.
New Contributor
waleswizard
Posts: 5
Registered: ‎06-28-2011
My Device: Playbook
My Carrier: Sonic

Re: Invoke.browser Issues - Playbook

hello armandopcm

thanks for reply my post, the problem in my webworks app is when i want to share content to facebook i use blackberry.invoke.BrowserArguments and succes open new window browser with link i pass from my apps but after that when i back to my apps is freeze i can't touch any link and button, to run normal again i must close my apps any run again from zero

Please use plain text.