We are looking on building a project that would run on Android, iPhone and other platforms with Phonegap. The app would be fairly simply, making use of the camera and basic UI features. The first versions would simply point to a web service and load information from there.
Over time, however, we want to improve the speed by:
1.) Downloading content via a separate thread when the app is running and storing the results in a local database,
2.) Hosting a mini webserver in the app*, and
3.) Pointing the PhoneGap UI to the app's mini webserver instead of the service's external webserver.
Two questions:
1.) Is it technically possible to host a mini webserver in iPhone that the app will access?
2.) Would this functionality be rejected by Apple?
Thanks in advance.
*I realize this step probably isn't really necessary. But, if it enables to truly build a "write-once-run-anywhere" UI, it might make sense still.
You're much more likely to want to have the HTML for presentation generated on your actual server, downloaded and stored by your separate thread as an .html file on the iPhone filesystem and served through local URLs using PhoneGap. Essentially, an advanced cache.
This way no web-server is necessary and you only need to write the UI generation code once on the server.
Related
I just found out that an iPhone can act as a web server to access the app's data. I'm using Xcode. How do I extend my app's capabilities so that users can edit app data using a Mac. Where can I learn about this? Can you give me summary and a website please?
I hope it's using Apache Tomcat. I suppose I have to build a website to process and display the app's data. I wonder if iPhone supports jsp since it's using UNIX. I really don't want to use PHP.
Currently Money Manager has that feature.
Searching for embedded iOS web server returns a few solutions:
Run a webserver on an iOS device
A small, lightweight, embeddable HTTP server for Mac OS X or iOS applications
Lightweight GCD based HTTP server for OS X & iOS
You will be unlikely to fit php or tomcat onto an iOS device; the lack of memory and processing power will be technically challenging.
Apple will also likely take a negative view of the inclusion of a general purpose scripting language in any app your submit to the App Store.
For iPhone and iPad i.e iOS development
Is there a specific server platform required to setup for
development and deployment enterprise apps?
Is there a specific architecture for this purpose? If so which one
since we are will be calling windows web service.
Is an application development server required or can we use an
ordinary pc?
Thanks in advance
Your server doesn't need anything special to distribute apps, we have it working fine on an ordinary Linux box. All you need is:
a URL to an XML file that describes the app
a URL to a png image for your app icon (for use while the app is being downloaded)
a URL to a .ipa file containing the actual app.
some kind of authentication to ensure these URLs aren't publicly available (this could just be a VERY long random string inside the URL, perhaps one that changes regularly).
All of that can be done on any ordinary HTTP web server, without even any dynamic pages.
Some other enterprise features, such as push notifications, will require a programming language that can do some fairly low level network stuff. We've got that working fine with PHP, I'm not sure what would be the best language to work with on Windows.
I'm not sure if this is what you're asking, but you will need a Mac OS X based workstation for writing and compiling the app(s) you're working on. This cannot be done on windows.
1) No
2) It's up to you. For instance you could feed XML or JSON equally on your windows web service. The way you call your server from the client on the app is your decision. Typically driven by a URL.
3) No, an application development server is not required. You can use an ordinary PC if you wanted. I've done this multiple times for testing sure. But for a large audience of course I would recommend something large like a linux server and not a "home PC".
I am about to develop an application for iPhone using Sencha Touch + PhoneGap and I have a few very basic questions:
1)I want to read an XML file which is at the location http://abc.om/app/a3/. I used Sencha to read this xml but its giving me the following error:
XMLHttpRequest cannot load the url. Origin is not allowed by
Access-Control-Allow-Origin.
Is this the right method/approach to use Sencha for reading the XML? If yes, then how do I resolve the above issue? Someone said that Sencha is client side, and it cannot read the Xml out of the domain - is this true? What happens in a mobile application? Should I use Phonegap here?
2)As I am developing an app for the iPhone, how should I check the app
- using Chrome? Or using phonegap each time and then check it on an iPhone?
In general, PhoneGap applications do not suffer from cross-domain security restrictions once they are deployed to a mobile device. The reasons for this are different depending on which platform you are developing for, but for iPhone, it is because the your local PhoneGap assets are loaded into the browser on the iPhone using the file:/// URI; this allows you to get around the cross-domain security restriction. If you are creating a regular web site that is being hosted on a server, then you are restricted by this security policy. It is one of the benefits of creating PhoneGap applications.
I am not 100% familiar with Sencha, but you can use whatever framework on top of the basic XMLHttpRequest object to do cross-domain communication in PhoneGap. Be it Sencha, jQuery, xui, MooTools, etc.
For testing PhoneGap applications, I usually use a combination of my desktop browsers and some extra tooling to help me. In your case, if you load your PhoneGap application locally on your computer into a browser like Safari (which allows you to make XHRs off the file:/// URI), you won't see the cross-domain problems. Safari is one of the few browsers that allows you to do this. Alternatively, you can use a proxy on your local computer and have your local web server make the network requests and proxy them back to your application. I tend to use an awesome tool called sleight, which is a node.js web server that will reverse-proxy requests to a target external domain if the server can't find the requested asset locally on your computer. I'll try to lay out an example use of sleight for you:
Let's assume your PhoneGap application assets are located under ~/src/www, with the app being in index.html
Also assuming you want to access the abc.com domain from your PhoneGap app
You would use sleight like this:
$ cd ~/src/www
$ sleight target=abc.com
Now you have a local web server running that serves up all content under your www directory. From your index.html page now you can dispatch XHRs to http://abc.om/app/a3/, and sleight will proxy those back to you. So you can point your browser to http://localhost:8088/index.html and you'll get your PhoneGap app's index.html.
Sleight is an awesome tool for PhoneGap development as it allows you to test your PhoneGap apps on-the-go locally on your computer.
Regarding question #2:
You can use "chrome --disable-web-security" to bypass the same-domain restriction and run your phonegap application.
Edit: As as Chrome version 48, you should also add the flag "--user-data-dir". See this question.
Regarding question #2, Ronenz's answer works.
Also you can find several extensions of Chrome.
For example, I am using this one, easy to enable and disable:
https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi
I'd like to build a simple native iPhone app with tools traditionally used for web apps.
I would prefer to use something like jQTouch and Rails, but I want it to work offline (not require an internet connection or a server).
Is there a framework that enables simple creation of native iOS aps by encapsulating a lightweight web server and a server-side app framework (Rails or something simpler and more lightweight that can run on a phone), thus allowing you to write the client side code in HTML+JavaScript ?
If there is not such a thing, is there a way to create an app (with HTML+JS) that basically only has a client-side component with persistent data storage?
Thanks.
Have you tried Phonegap?
www.phonegap.com
You write your app in HTML/CSS/JavaScript.
You access the phones APIs through JavaScript - boom!
Also; Appcelerator Titanium would be an option: http://www.appcelerator.com/
-IMO Titanium is more powerful, and offers a more native look.
Why would you want to run a webserver off of the iPhone?
Is it so that you could send back data to the mothership?
Yes, you can included a lightweight http server running in another thread inside your iPhone app, and have your UIWebView connect to it. But unless you are going to do a fancier web server that generates dynamic content, it might be easy to just download your HTML/CSS/Javascript content to a local directory, and then point any URLs to those local files when offline.
I really want to run my test websites from an iPad to show to clients but I don't want to have to rely on the 3g connectivity or wifi. Can I run sites that are compiled from an App or something similar on the iPad?
I have seen Mono Touch but I wanted first hand views on this as if I can I'm going to buy an iPad ASAP.
You can use Service Stack to create web services. I'm sure you can serve up HTML one way or another. I haven't tried it.
What you're looking for is IIS or Cassini for the iPad, which doesn't exist, as far as I know.
Using MonoTouch, you'd have to create a native app that simply functioned as a browser shell and served up HTML. MVC works in Mono, so you could do it using a local db, but it would be a lot of work, and I'm not sure what that would buy you... Other than an iPad, which just might make the effort worth it. :)
Hmm, a bit of a hack, but extending waht ifwdev said, if you can expose services as JSON endpoints, you could mock the UI using raw HTML and Javascript instead of server side code (PHP/ASP.NET etc).