PhoneGap (iPhone / Xcode 4) All links open in Safari - iphone

I installed PhoneGap in Xcode but every link I place in the HTML open in Safari, is there a way to get around this? (Even window.location = ''; opens safari)
Also does anyone know how you can start with a remote address instead of a local?

Late response, but here's what I found out if anyone stumbles across this that doesn't require using the ChildBrowser plugin mentioned earlier.
Cordova.plist (found in the Supporting Files folder) has some settings for determining this behavior:
The URLs need to be added to "ExternalHosts" in order for them to be whitelisted (add as
many as needed & you can use * as a wildcard).
Set "OpenAllWhitelistURLsInWebView" to YES.
There might be other settings worth configuring there as well, but those two should prevent links & window.location from opening via Mobile Safari.

I've never used it, but often see others referencing the ChildBrowser plugin, which looks like it may fit your needs. You can check out the readme.txt for more info.

Related

How to launch an external website from a chrome app?

I'm looking to link to a sign up page on an external webapp via a chrome app. The simplest way to manage this seems to be to open a new tab in the chrome browser (not a new webview in a new window of the app).
Tabs seem deprecated and a webview appears very unofficial and unsafe. Basically, is there a way to effectively do this:
Sign up
And the bigger question of course: is there a better way to approach what seems like a simple problem?
Your conceptions, "Tabs seem deprecated and a webview appears very unofficial and unsafe", seem very strange. tabs is simply not enabled for Apps, and <webview> is alive and well.
But if you must open it in the browser, window.open will do the trick. See also this question.
Edit: Also, upcoming is the chrome.browser.openTab API. Leave your feedback if you have use cases for this feature.

How to deal with missing hw back button on iphone in a phonegap app?

I have a web app, hosted in a phonegap application (i use phonegap build for this)
The setup is simple, but shouldn't really matter in this case. I'll tell you anyways because sometimes the devil is in the details, right? :)
The details
The phonegap app is really just the minimal setup with one single html. That html actually serves as a splashscreen - the background of HTML has an image. There is a meta refresh tag, set to redirect the page to an external url. I'll call it myurl.com from now.
The website at myurl.com is build using jquery mobile and angularjs. I use that adapter floating around to handle the problem with both frameworks wanting to manipulate the dom on page load. This is the domain the app is really hosted on and where the whole application is run.
The setup
One page has a link to an external page. That page has a bootload of javascript, showing some fancy stuff. If you click the link - your app takes you to that page. That is great! It actually works on all devices. On my desktop browser and android app, i simply hit the hardware (or browser) BACK button and i'm returned to my app at myurl.com. Iphone on the other hand doesn't have a back button :(
My first attempt is creating a landing page that has a back button/link and an iframe to host the fancy page. It works on desktop and android even though i get some exceptions/errors in the console. It doesn't load on iphone - i can only suspect security issues. I am told that what i'm trying to do with the iframe won't work which i think is true.
How do i deal with this? I actually tried the InAppBrowser like this:
var ref = window.open(url, 'random_string', 'location=yes');
And i checked my config.xml has this:
<preference name="stay-in-webview" value="false" />
I also added this to my page:
<script stype="text/javascript" src="phonegap.js"></script>
Leaving out the phonegap.js file since phonegap build promise to include the correct version.
It still opens the page in the same view/app without the possibility to go back - i get the excat same result as just opening the link the normal way.
Help me {insert jedi name here}, you're my only hope!
EDIT:
I found the problem. The phonegap.js file is automaticly deployed ON the device so only the first index.html (with the meta refresh) actually links correctly. The pages on myurl.com is not linking to the file. I placed the phonegap.js on myurl.com and it's working. Only problem, the phonegap.js is different per device - meaning only the device i picked the phonegap.js from is working - the other devices break!
Anywhere i can link to the native apps files? i tried file:///{path}/phonegap.js but it doesn't work. I can see/guess the path, which is different per device, but for iphone its
Payload{name}.app\www - it won't load from there though... i also tried
http://localhost/phonegap.js
but that doesn't work either.
Any ideas?
FINAL EDIT
I decided to go back to the drawing board and place all the html files on the device instead. I'll implement JSONP on my ajax api instead so i can let the API live on myurl.com and still access it from the phone. It's probably also the intended way to make a phonegap app - i just liked the other approach more...
I actually just answered a question like this the other day. You can find it here. In short, see below:
Ensure you have <script src="phonegap.js"></script> in each of your pages that wants to use the inappbrowser
You should NOT need to include a plug-in tag in your config.xml. I am pretty sure that around 2.5 they included inappbrowser in the core build functionality.
To open a link in the inappbrowser, use this javascript:
function openURL(urlString){
myURL = encodeURI(urlString);
window.open(myURL, '_blank');
}
This will open the passed URL in the inappbrowser. If you change window.open(myURL, '_blank'); to window.open(myURL, '_system'); it will open the passed URL in the system browser.
Finally, your item clicks look like this:
<a href='#' onclick='openURL("http://www.urlyouwant")/>
Also, depending on the version of phonegap you are using, stayinwebview is depreciated.
***Based on your edit: Do not put phonegap.js in your project directory. When you upload it to build, it will include it in your project.

how to create a webview in blackberry which allows me to only view the page and disable all other options

How to create a webview which gives me only option of viewing the webpage and the rest of the options should be disabled.
BrowserSession browserSession = Browser.getDefaultSession();
browserSession.displayPage("http://www.google.co.in/");
I tried this code but not able to disable the options in the browser.
Looks like you have the wrong tag of 'blackberry-webworks' for your post, sounds like a Java question?
In any event... BlackBerry WebWorks is essentially a webapp/webpage running natively on a device.
If you were to use WebWorks for development, you would simply create a webpage (html, css, javascript), and create a config.xml file which tells the SDK what your app is, what it wants access to do on the device, and request needed permissions, etc.
Once packaged, your app would run like any other app on the device. The cool thing about WebWorks is technically you can create a launcher for a website. It again would look like any other app, have it's own icon, and launch in it's own webview. You wouldn't have any of the browser address bars, or anything like that, so this may be the way to go.
If you want some 'Getting Started' info, check-out the HTML5 WebWorks webpage
I got the solution. It may help somebody
BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
BrowserField browserField = new BrowserField(myBrowserFieldConfig);
add(browserField);
browserField.requestContent("http://www.google.co.in");

Open source web browser for iPhone

Is there any open source web browser for iPhone?
Here is an article about some available web browsers for the iphone, none of which I believe are open source. Double check to be sure though:
http://www.pcworld.com/article/157060/first_look_new_web_browsers_for_iphone.html
You may also want to check out sunrise which is open source, but I don't think it's available for the iphone yet.
http://www.sunrisebrowser.com/
Other then that, I think you may be out of luck :(
Webkit is open source. You can start with that.

Simplest way to incorporate iPhone file upload when building app with Appcelerator's Titanium Developer

Sorry for the long explanation. Thanks in advance to all who are taking their time.
I am an Ubuntu user who has set up Titanium Developer on a MacMini in order to build an app for the iPhone (and ultimately some other platforms).
Rather than having any local code built in, the app simply points to my website. To do that, all I needed to do was change Titanium's tiapp.xml file to include my website URL. I wrote no other code, nor did I need to include any other files. It simply compiled and ran in the emulator without a hitch.
I've got just one problem: I need to upload files to my website and Apple, as most of you know, has disabled the input field type=file. I've got it working in all other browsers. The action simply calls a php file and passes the file info.
If I didn't have an app, and someone was just manually navigating to my site with the iPhone's Safari browser, I could get around the problem by using CliqCliq, which is a very cool iPhone app. Basically, I use JavaScript window.open() to launch CliqCliq's QuickPic browser in a second Safari window. The user chooses a file; QuickPic uploads it; and the user is returned to the second Safari window that I launched with window.open(). The user closes the window and Safari returns them to the first window (i.e., my website).
The problem is that my website is being shown in my app. (By the way, I don't have my developer license yet, even though I signed up a few weeks ago, and I can't test this in the emulator because I can't install QuickPic into it, I assume.) I wanted to repeat the same steps, described in the previous paragraph, using an iFrame but that didn't seem to work (i.e., the iFrame was blank despite my designating a src). I also tried having a hidden window by using old-fashioned frames and setting the col-width to 0. That also did not work (i.e., Safari, if I recall correctly, opened a separate window).
I'm working a little blind, since I can't test anything on the iPhone, but I figure I have two options: I can either find a way to launch a QuickPic in an iFrame -or- I can find some way to incorporate the Apple toolkit file chooser into the Titanium app.
The problem with the first option -- but again, I don't know until I can try this on the iPhone -- is that I assume both apps (mine and CliqCliq's) could not run at the same time. Even if I had a hidden window, invisible iFrame, etc., the moment it launches QuickPic, I assume my app would quit(?).
The problem with the second option is that I don't have clue as to how to incorporate a file picker into my app by using Titanium (keeping in mind, everyone, that I know very little). Brian at CliqCliq has even offered to give me some code if I can't make Apple's file picker work but again, I'm not sure what to do next.
What do you folks think? What's the best method? And, what's the easiest thing for a simpleton to do?
Thanks.
<input type="file"> is not supported on the iPhone. You'll need to use Titanium's APIs, specifically the Media one (openPhotoGallery or showCamera).
As a side note, Apple reportedly rejects apps that are just a webview displaying a website. You may want to consider putting most of the app code in local storage and using AJAX to fetch content.