Building a native mobile application - based on a PHP web-app

10,694

Solution 1

I'm not a phone developer myself, however I've just finished building a native Android App which connects to a website and is able to login, do stuff that is possible to do on the website as well. If the GPS tracking integration is using the native features than it is unlikely to use HTML5 (though I'm not sure how it works).

Basically in order to connect to a remote database/server you need to make HTTP requests from the phone to you server side script.

So just to conclude: In order to achieve the result you're looking for the work-flow could look like this:

1.Mobile user fills a form ->

2.App does an HTTP request to a server side script ->

3.script does the hard work (e.g. connects to the database) ->

4.script renders a result ->

5.Mobile app displays the result.

I hope this helps.

Solution 2

Im my objective opinion there are three possibilities:

Get started with Objective-C

You will have to learn how to code and you will get the best native experience for your users. This will easily allow you to use the GPS positioning or you can cache content on your phone. A key problem with the internet connection on the phone is that the internet connection can be flaky. So you have to design for this. You took the right approach already: using the direct MySQL C-API to connect directly to the database server would not work that well, because this protocol is not stateless. You have to first login to the server and then you can send your SQL queries.

By using your API which is hopefully stateless, maybe even a RESTful API, then you can take some nice shortcuts for your native iPhone app. You could then use the RestKit library to easily convert your JSON answers from the server into objects, do caching and other nice features.

Write a web app

The second possibility would be to build a nice web app using state-of-the-art HTML5 technologies. The great thing about that is that you then would write an Android app as well as both mobile devices use a webkit browser. Well it is not exactly the case as there are different versions of Android out there with different screen sizes, but in general this assumption holds. Take a look at Google's web app for Google Calendar for example, I think it is a good compromise. You can also get a home screen icon for this and you will have no app approval process and can update anytime. Using HTML5 offline storage gives you some degree of freedom.

Using Phonegap

The option of writing the app in PhoneGap or some other HTML wrapper framework which will generate Objective-C code is a possible one, but in my opinion this is not really a good option. The reason is that you are working on some kind of intermediate layer and if anything goes wrong or you encounter bugs you will have to dive down to objective-c anyways. The other problem is concerning updates of iOS. It can break some dependencies and then you have to wait until your intermediate gets updated to use the new features.

Solution 3

Phonegap would be a good idea to develop this app. Phonegap although supports client side script only - which means you cannot embed php in its code. However you can easily create AJAX calls in your script that get and send data from your already developed php app/api.

Phonegap also supports GPS and data storage options where you can store the data locally and sync later when internet is available.

For reverse sync (server to client), you would have two options. 1. Create a javascript to make frequent ajax calls to check for updates. 2. Use Push Notifications (Here a tutorial for iOS APNs and Phonegap integration) - http://devgirl.org/2012/10/19/tutorial-apple-push-notifications-with-phonegap-part-1/

Using phonegap depends on one's preference. On the positive side, you save on time/cost as same code is used for all platforms. On the negative side, it has a slight lag when changing pages causing it to look like a website, but you can avoid that by using something like jquery mobile to prefetch all pages and then animate them back and forth. This will also help in uploading data in a separate independent thread while the user would be free to roam around the app.

Hope that helps.

Share:
10,694
Samwise
Author by

Samwise

Updated on June 23, 2022

Comments

  • Samwise
    Samwise about 2 years

    I have had a PHP application developed. I want to use phonegap.com or a similar approach to develop native applications based on the same MySQL database. In other words, connect the mobile applications with the web one.

    It needs to do one or two things differently. Firstly, use the native GPS features to determine where a user is - I'm guessing this can just be done via HTML5?

    Secondly, send push notifications whenever the web-application user receives a notification.

    All of the information is already there, on the MySQL database, and everything apart from the two features above function properly.

    I'm am currently having an API developed for everything on the web-application - making it API-centric. In my head, it will be easy to connect the two versions via the API.

    For example, a user signs up on the web application. He is then offered to iphone app for download.

    Is it possible to get him to log-in with the same via the iPhone. On the other side, is it possible for him to search the database, via the iphone, and "add a new friend" - making the connection of the two users in the friends table - in that, the friend is also a friend on the web-application?

    I've been reading a lot on all of the available options and am still very confused! Any help would be very helpful.

  • Samwise
    Samwise about 12 years
    So, in your opinion; it would be better to solely create a mobile-web version of the web appliacation - different UI etc. Then allow the user of iPhone, Android etc to create a shortcut from their home-dashboards/springboards? Cheers for that answer, very helpful!
  • GorillaPatch
    GorillaPatch about 12 years
    Well yes and no. From a technical point of view that would make sense. Often customers just WANT an app, no matter what. In this case a thin wrapper layer would do (basically a second web browser for you app only). BTW if you find the answer helpful, feel free to up vote it.
  • Angel G. Olloqui
    Angel G. Olloqui about 12 years
    But creating a webApp do not solve the problem of receiving APNs. You should go for the native one if you need such a complex app.
  • GorillaPatch
    GorillaPatch about 12 years
    What is an APN ? - However a native app can be surely more polished and take advantage of more iOS features than just a web app.