You need to sign in to do that
Don't have an account?
Mobile SDK 1.5 and InAppBrowser
Has anybody had any luck using the InAppBrowser? According to the cordova docs, this is available in 2.3.0 and it appears in my config.xml. The docs say that if I execute JavaScript of the form:
window.open('http://www.google.co.uk', '_blank', 'location=yes')
then it should open the page in the InAppBrowser, leaving my existing app alone. I've tried every combination I can think of and tinkered with the whitelisting, but all to no avail - every page opens in the cordova webview.
I'm trying to get this working so that I can open a PDF file via a link from my app and have a way to close it down and return to my app. At the moment, when I open the PDF, I have no way to get back to my app. I can workaround this to a degree using an iframe or object tag, but the interaction with the file for scrolling etc is very slow.
Stupid question: are you serving the cordova.js file from your VF page? For Cordova apps in the cloud, you must serve the JS artifacts from your VF page; the ones used in the container are not sufficient.
I am able to successfully execute your VF scenario almost exactly (my anchor was something like <a href="javascript:loadInAppBrowser('http://www.google.com');">Test InAppBrowser</a>, where loadInAppBrowser() was just a helper function I defined in my page to do your window.open, but otherwise exactly the same at the end code).
All Answers
Does www.google.co.uk fall into your whitelist, and if so, what's the value of OpenAllWhitelistURLsInWebView in your config.xml file. If the former is true, and the latter is true, these links will open in your main webview, even with the window.open call you describe.
My setup from config.xml:
and the link opens in the web view with the following in the log file:
If I remove www.google.co.uk from my whitelist (which according to the docs should cause it to be opened in the inappbrowser) I get an error that the link was denied due to the whitelist.
My app is served from Visualforce pages rather than content in the www folder of the hybrid app, if that makes any difference (I haven't found anything indicating that this is a problem).
So here's what I've come to find out:
But back to your original issue, though I can reproduce whitelisting issues, I cannot reproduce a scenario where InAppBrowser does not open at all (in favor of the main web view).
FYI, a patch has been posted for the Mobile SDK, if you want to see if that helps at all with your problem. It fixes the whitelisting issue, anyway.
Thanks for looking into this. I've isolated what is happening and it appears to be due to the fact that I am using a Visualforce-based application and my pages are accessed from Visualforce and I start the app using SFHybridApp.RemoteAppStartData.
If my visualforce page is simply:
the page opens in the webview.
If I change my app to use SFHybridApp.LocalAppStartData and put the anchor tag from above into index.html, it opens correctly. I've been digging around to see if I can find anything to indcate that local/versus remote apps would behave differently, but I haven't come up with anything.
Do you know if this is expected behaviour? I'd prefer not to have to change to a local app as I'll be updating the information presented frequently and I'd like to avoid having to push out repeated updates.
Digging a little more, I can workaround this by having the index.html in the local app open my visualforce page in the inappbrowser, and then I at least have the navigation buttons when I open PDFs etc. I'd still be interested to know if there's any way that I can use the InAppBrowser from the remote app - the debug logs and whitelisting indicates that the app still has control over the navigation.
Stupid question: are you serving the cordova.js file from your VF page? For Cordova apps in the cloud, you must serve the JS artifacts from your VF page; the ones used in the container are not sufficient.
I am able to successfully execute your VF scenario almost exactly (my anchor was something like <a href="javascript:loadInAppBrowser('http://www.google.com');">Test InAppBrowser</a>, where loadInAppBrowser() was just a helper function I defined in my page to do your window.open, but otherwise exactly the same at the end code).
That's the perfect question, as I was not serving cordova.js in my visualforce page!
I've just added that and its working a treat.
Thanks for all your help!
Glad it turned out to be a simple fix! Thanks in turn for unearthing some bugs that we missed. :)
Thanks Kevin and Bob for the troubleshooting and resolution. This was the aspirin I was looking for to solve my headache.
Thanks