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
Related
I've spent the day googling all the leads on developing iphone apps on Windows and apart from buying a mac the most suitable route seems to be Phonegap. I cannot find out whether Phonegap gives access to all the native functionality. For example I want to access and manipulate the address book contents. I also want to be able to send text messages programatically and intercept and examine incoming text messages. It would be helpful if someone could confirm whether this can be done with Phonegap.
My understanding is that Phonegap is based on webapps but I am assuming that an app developed with it can run offline for operations that dont require internet access.
Even using Phonegap you will still need access to a mac to actually build your iOS application. This is a restriction that Apple has in place, and to my knowledge there is no way around it.
Phonegap uses a UIWebView to display your application built using HTML, CSS, Javascript etc, but this does not mean that an Internet connection is required for the app to run (so offline apps are definitely possible).
With regards to Phonegap's functionality, details of the Phonegap API can be found on their website. Specific to your needs, I believe phonegap provides access to the device's address book through the contacts API:
http://docs.phonegap.com/en/2.3.0/cordova_contacts_contacts.md.html#Contacts
I don't think Phonegap provides the ability to send SMS messages itself, but many people have developed extensions to add extra functionality to their applications through plugins. The majority of Phonegap iOS plugins can found at the following GitHub repo. The plugin I think you require is the SMSComposer:
https://github.com/phonegap/phonegap-plugins/tree/master/iOS/SMSComposer
I have tried looking for some answers but could not get anything concrete from the other questions in here.
I am looking for an answer to these two questions:
Using PhoneGap, if I create an iPhone web app, can I use it as
plain web app (i.e. without using iTunes to deploy it)? Just via a
web url?
Using PhoneGap, can an iPhone web app check for wifi
connectivity? i.e. If wifi/3g is available, if wifi is available,
can it scan for ssids.
Thanks for any help in advance.
You can create host the web app on your own server (or local). Then it is accessible via web url. If you want to use it as a normal app (there are differences - phonegap uses few native plugins for better experience), then you must have a developer license from apple and then deploy it to your device. Otherwise you can only use the simulator. You can also use Safari + USB to debug your app using the browser.
It is possible but limited. Only certain functionalities are available. Check out the following plugin for cordova (phonegap):
cordova-plugin-wifi
Good luck!
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.
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.
I am new to wordpress and I want to create an interface for being able to access my database hosted on wordpress in my mobile applications - particularly iPhone and Android.
As these do not directly access SQL databases and would need routines on the server-side for being able to do so, what would be the best way for me to go about writing these routines/web-service calls?
Are there any wordpress plugins available for this? If not, what language should I use - php or something else?
I need some lead.
Perhaps you do not need to access the database directly?
Wordpress supports the XML-RPC standard interface so applications can communicate with WP across the internet, without needing access to WP's database. http://codex.wordpress.org/XML-RPC_Support
If you choose to implement your apps' using XML-RPC, all your communication will be reduced to simple HTTP calls.
To get started I suggest checking out the source code of Wordpress' own iPhone application, which utilizes XML-RPC http://iphone.wordpress.org/
Also, note that Wordpress has published an extension to the XML-RPC API that includes WP specific functions: http://codex.wordpress.org/XML-RPC_wp
I would suggest creating a webapp (iPhone style) for the phone application and calling everything with AJAX to a PHP (Due to Wordpress running PHP) backend to validate and execute the queries. iPhone webapps dev link I haven't found any solid tutorial/resource for developing BlackBerry webapps (Please post back if you find one)
Instead of creating a new app, or trying to port the database, check out WP Touch, which is a Wordpress plugin/theme which will turn your wordpress install into an iPhone friendly site on iPhones.