Database Driven iOS Apps - mysql

So this is more of a general question about apps and techniques rather than a specific code question...
When developing an larger app, how would a developer access lots of data from a website. The example I'll use is an app like Yelp. They have both a web-access site and an app, both share the same information. I would imagine that information like that is stored on the website via some sort of MySQL database and the iOS device access's it as needed based on the user's requests.
How might a developer writing an app start something like this? I assume you need to somehow securely tie the MySQL database to iOS and so on. I've seen a lot of techniques on the web, but they all seem very simple and not safe for a large scale app.
Any ideas would be awesome!

The key term you're looking for is "API" (Application Programming Interface).
A Yelp iOS app won't access Yelp's databases directly. There will be a layer (I simplify here somewhat) between that and the iOS app; this layer will provide a series of methods (the API) by which clients can make queries and potentially manipulate remote state.
A common API format is JSON over HTTP, and indeed, this is what the official Yelp API seems to be.
Good starting points would be the documentation for NSURLConnection and NSJSONSerialization, and the Yelp API documentation I link above.

Related

Connect Sproutcore App to MySQL Database

I'm trying to build my first Sproutcore App and I struggle to connect it to a MySQL-Database or any datasource other than fixture. I can't seem to find ANY tutorial except this one from 2009 which is marked as deprecated: http://wiki.sproutcore.com/w/page/12413058/Todos%2007-Hooking%20Up%20to%20the%20Backend .
Do people usually not connect SC-Apps to a Database? If they do so, how do they find out how to? Or does the above mentioned tutorial still work? A lot of gem-commands in the introduction seems to already differ from the official Sproutcore getting-started-guide.
SproutCore apps, as client-side "in-browser" apps, cannot connect directly to a MySQL or any other non-browser database. The application itself runs only within the user's browser (it's just HTML, CSS & JavaScript once built and deployed) and typically accesses any external data via XHR requests to an API or APIs. Therefore, you will need to create a service wrapper around your MySQL database in order for your client-side app to be able to load and update data.
There are two things worth mentioning. The first is that since the SproutCore app contains all of your user interface and a great deal of business logic, your API can be quite simple and should only return raw data (such as JSON). The second is that, I should mention that the client-server design, while more tedious to implement, is absolutely necessary in practice, because you can never trust the client side code, which is in the hands of a possibly nefarious user. Therefore, your API should also act as the final gatekeeper to validate all requests from the client.
This tutorial I found helped me a lot. Its very brief and demonstrates how to implement a very simple login-app, how to send post-requests (triggered by the login-button-action) to the backend-server and how to asynchronously process the response inside the Sproutcore-App:
http://hawkins.io/2011/04/sproutcore_login_tutorial/

Mobile App from Web App, caching data/login

I have a given Javascript browser application with login screen and data display screen. It does request JSON data via calls that are always the same (i.e. http://myserver.lol/api/getData?mobile), the data changing only slightly over time.
What I want is a mobile app for Android/iOS/Windows Phone/Blackberry, which
-> at best "caches" the whole web site (html/js...) in the app, so I don't have to rebuild the app whenever the web app changes;
-> provides some form of "auto-login"/"auto-form-fill", so the user does not have to give his credentials every time, and
-> some kind of long-term cache for the JSON data, so it is requested from server when a fast network connection (LTE/WLAN) is available, but taken from Cache on GSM or without connection.
Which Framework would allow to implement this the easiest? I am just now looking at the PhoneGap docs and the Titanium docs, but I guess I am overlooking something, or don't they provide an easy solution for this? Or perhaps you have an insider tip for me on another framework?
You can definitely handle this buy using both frameworks. I use only Phonegap / Cordova.
I would do this all by building the application with Phonegap together with AngularJS.
You can use templates in there, so you don't have to fetch the Ui from your server.
To cache data (user credentials or JSON data) I would just use the localStorage which is available on all devices (see here).
I recommend angularJS because it is a really great framework which helps you build Web-Applications really fast (but if you already have an existing application this might not be an option for you).
I hope this helps ;-)

MySQL into iOS Application (Xcode 5)

I am new to app making, but I have a small tech review site that I am trying to grow and I want to make an app for. Its pretty simple what I am setting up. To start, I am using MySQL to have three basic things. The review's picture, the title, and the review itself. The idea of this is so I can have other users log in to write reviews and it can load easily on an app, the website, etc... The most trouble I am having is in Xcode trying to make an app for this. I want two basic screens. A list of all the reviews with the picture on the left, and the title, and when you click on it, it takes you to the second screen displaying the review itself. Does that make sense?
(I am using Xcode 5 on Mac OS X 10.9. This App is intended for iOS)
-Thank You!
*Moderators, I apologize if this is a duplicate question, I have searched and have not found an answer.
If I understand correctly what is your asking then you probably need to rephrase the question and edit the tags. Because it has nothing to do with xcode5, mysql, uitableview or even iOS.
Before you start designing your iOS app, you need to think the overall architecture for your service. The client iOS app shouldn't (and usually can't) communicate directly with a database server (mysql in your case), you need to think about a server side API layer for your iOS app to consume.
You need to outline your web API and decide what is its interface (entry points, resources, data structures), take a look at REST architecture, for example. Decide on your data exchange format (e.g. JSON, XML). Then decide what platform and framework you want to create your API layer with (e.g. PHP, Python, Ruby on Rails, Asp.net etc).
Your iOS app itself sounds like a simple classic Master-Detail pattern and what you wrote is a good start (Google for master detail examples, plenty of them for iOS as well). Your question is too broad here, you need to be more specific in order for people to be able to help you with the app itself.

An alternative to app engine to use drive api?

I basically want to write an app that uses the Drive API. developers.google.com has tutorials on how to do that. But problem is that their example asks me to first create an app engine instance, which I don't want to, as I've heard pretty bad reviews about it. So, I just wanted to know whether there is/are any alternative/s available, and what challenges I would possibly have to face when using the service/s.
You can write a Drive app on any platform that can make an HTTPS request, so pretty much, any platform. When you choose one, if you have any problems, get back to us.
Also, you should probably try out App Engine before making a decision based on "reviews you read".
AppEngine has a few convenience classes around Credential storage and User Id. Aside from that a standard servlet app and a GAE app are pretty much the same.

developing location/map based web site

I wanna start developing a map-based web site.
At first I ordered a regulat Gps device just to test the site, later on I would like to use Iphone's gps and other cell devices.
So I need something pretty generic.
I searched the web for map-based development framework and come up with too many of them :
Geo server, Map server, Open layers, Geoext , Google maps's api , and more.
I'm not a seasoned web developr (more of a c++ kind of guy) so I need something pretty straightforward , though robust at the same time.
Moreover, I need one which is free, and won't have licensing problem down the road.
At first I just need basic capabilities as displaying the gps data on my web site in real-time.
Can someone experienced recommend one ?
Thanks
Client
I'd go with OpenLayers - this is an opensource JavaScript client library, similar to the Google Maps API, or Bing API. However OpenLayers will free you of any licensing worries, or changing APIs as the source is available and can be modified - this is not the case with the Google/Bing/Yahoo APIs. You can however use the data from these services as layers in OpenLayers and drop them if they suddenly become filled with adverts or have commercial restrictions.
Have a look at examples to see if there is one you can use to make your first test application - http://openlayers.org/dev/examples/
GeoExtJS is a collection of extra tools and widgets that work with OpenLayers, built on top of another JavaScript framework ExtJS - also open source. ExtJS is mainly used for building user interfaces - data entry forms, grids etc. using JavaScript, to display in the browser.
If you are looking for tree structures to switch layers on and off and other more advanced UI widgets then GeoExtJS is worth looking into.
Server
If you are only displaying points then you can create dynamic KML or GeoJSON on your web server and reference this in OpenLayers. There are libraries in all languages that you can build on. Python has become a key languages in geospatial technologies, and has GeoJSON libraries you could script with.
GeoServer and MapServer are both server-side programs that allow you to serve out spatial data from databases with symbology, labelling etc. If you are having lots of different datasets then its worth spending time setting this up.
MapServer is written in C++ so it is probably easier for you to try this - however you may be able to get away without needing any specialist server side software, especially if your data consists of X,Y / Lon,Lat values that can be easily plotted as points.
For the beginning (you said that you need to show gps position in a real time) I think that Google Maps are good option here. This solution has very simple API and community support is also an advantage here (I've never compared with something else but I have good experince with GMaps and its tutorials/resources). This is for the client side, for server side any web framework should do the work (I use Django and it also have dupport for some geo things - mentioned later in this answer).
You need probably to build application that follows this rules:
Your GPS device sends data to your server(web application) periodically, data is stored in a db.
Users use browser to display data with map (eg. Google Map) which updates position periodicaly on some scheduled interval (eg. ajax calls to the server for the most current position). Each time response is recieved map need to be updated.
I don't know if there are more specialized solutions for this case.
If you need to improve your application and add some features you need to consider some more sophisticated geo frameworks. I have heard some positive opinions on GeoDjango, mainly because it can be easily incorporated with Django(which is very easy web framework to learn and it has a lot of capabilities).
All technologies I mentioned here are free.
I can recommend using the Google Maps API to render your maps in a browser. You can find my reasons in this answer.
The current version of the API has support for getting geo-location information for mobile devices.
I use Bing Maps for mobile. Mainly because its fast, and provides much better looking maps, 3d models, and satellite views for the UK than Google maps does.
I have also had issues with Google changing their service to provide some enhancements and it breaking my app, where at least with the Bing API theres a bit more compatability considered for existing apps. Not that I dont like the Google maps, I do. Its a backup service for me..
I generate maps from both providers, Bing as the primary, Goole secondary... this means that if ones offline of not working, which happens, my users still get to use my app.
Heres a link to Bing Maps Dev on a WIndows Phone for example
I'd take a look at Cloudmade. They have a number of API's, free options, paid options and use OpenStreetMap which for many places is one of the most accurate mapping solutions out there.
free , open source:
www.openstreetmap.org,
u can build ur own server as well using the same technolgogy:
http://weait.com/content/build-your-own-openstreetmap-server
API: http://wiki.openstreetmap.org/wiki/OpenLayers
Although its still in draft form, HTML5 will be supporting Geolocation API. Most major browsers and hand held devices should be supporting it in the near future and should make life a lot easier for developers who want a service independent solution. You would however still need a mapping service like google maps if you need to display locations.
function showMap(position) {
// Show a map centered at (position.coords.latitude, position.coords.longitude)
}
// One-shot position request.
navigator.geolocation.getCurrentPosition(showMap);
EDIT:
Its already supported in several major browsers:
Mozilla Firefox: supported in Firefox
3.5 and later versions.
Chrome: Supports thru Google Gears
Geolocation API
Opera: Supported in
nightly builds
Safari: Support is
coming soon in the IPhone’s Safari
browser.
Internet Explorer:
experimental support available from
IE8.