So I've built a web app in PHP that relies heavily on a MySQL database. Now (for user convenience purposes) I'm trying to create the exact same app, just as an iPhone app. Granted, I have no knowledge of Objective-C (just starting to learn it), I wanted to know how to go about this. I know that I'll have to use some kind of intermediary to get Objective-C to connect to the SQL database.
So essentially my questions are: If I've already created the web app as aforementioned, could I use the same DB and tables for the iOS app version as I did for the PHP web version? Also, is there anyway to migrate any code I've created in PHP to iOS (I realize that they are two completely different languages), but I'm just curious as to whether or not I'll have to build the iOS app from 'complete' scratch.
Your best bet is to write an PHP service to talk to your database.
This way you can share this API between your app or iOS app or any other type of client app.
The service will be responsible to receive request query the database and send responses in JSON format for example.
So to make things easier, you should not query the database directly from your apps, use a common web service.
You can use your MySQL database for any purpose because it is just data. The code that will show them will be different though. If you have no knowledge about Objective-C you should consider the web-app approach.
Here are a few helper links.
https://developer.apple.com/library/safari/referencelibrary/gettingstarted/gs_iphonewebapp/_index.html
http://gigaom.com/2010/02/12/how-to-create-an-iphone-web-app/
Related
I have an Android app a Simple form consist of some fields, I also have a Web server using Google App Engine in PHP. I was confused by This, should i send the Data from my Android app directly to my webserver, display the data in web server using local and then later on update thus data in datastore or should i send the data from my android app directly to the datastore and display in my webserver? I'm new with this Android and with this Google App Engine/Datastore, I hardly can't find proper Tutorials on Google App Engine using php. I think only few uses this thing.
Any Suggestion well do.
The typical solution would be to provide an API for your app. I'm not familiar with PHP these days but there are bound to be plenty of REST frameworks that will take care of all the JSON conversion for you.
Your API (assuming it's PHP) can then take care of doing any necessary validation, authentication, performing queries, etc, against Datastore. This may help.
If you're familiar with Java (you're writing an Android app) or Python, you can look at Cloud Endpoints.
If you want a PHP library to access Datastore from GAE, check this out:
https://github.com/tomwalder/php-gds
I've got a book I bought online - O'Reilly's Building Android Apps with HTML, CSS and JavaScript. The idea is that you can use these 3 to create a website that can be converted to an Android app by using a Java conversion tool.
Hopefully someone will be familiar with this, and hopefully this is possible - if I have a website that is already created that also includes PHP, could this be used for the app?
I've created PHP sites before, and the one I'm specifically looking at is referencing a MySQL database, hence my need to use PHP for the app. The website is heavily based on PHP.
No you can't (Unless you created your own framework which runs a local php server inside of the device which can be accessed by a webview). Php is a server side language. Html and JavaScript are client side. These html app creation frameworks use the webview to run apps. Be careful as there are performance issues when running through webview as it is not a native app (projects like crosswalk help but still many issues). Popular frameworks include ionic (Angularjs), titanium (is mostly native but from my experience limiting), and appgyver (Angularjs).
Yes you can! If by "converting" the website to app you mean displaying the website in a chromeless view mode (without address bar).
If you wan't to use phonegap / cordova you can still use the existing PHP code as backend for the database (Maybe rewrite it into a Restful API).
If you want your app to run natively and without internet connection, then you are out of luck though.
I've developed an android app that interact with my database by using some php scripts (one for each function of my app) that returns a json object with response data.
Now i need to build up a website too that do the same tasks of my app, but i would fix up my server code.
Should i have to maintain my app php scripts separate from website scripts (i'm planning to use some php framework to develop it), or there's a different way to do it?
No! Same script will work for all platforms.
If you follow proper protocols you will be good :)
Use Rest Console or similar tools to test your webservice on browser.
If you are able to get JSON response, then its good for all platform.
If you want to separate out the platforms and devices on server that can be handled by using user agent check at server end.
I have a website that uses MySQL database.
I'm trying to build an iOS app for it, so I wanted to use Swift to import information from the database and insert new information to it. I read that for the reading part I should use a PHP file to create a Json file, read that and extract the data. But I can't find the way to do it with swift.
Is there a way to connect iOS apps (written in Swift) to MySQL?
In the client-server architecture, the client is completely separate from the server, and they just exchange data thanks to a common "language" (in your case, certain fields encoded in JSON).
Your client is your iPhone app, written in Swift (but that's irrelevant).
You now need to build a server, which is entirely separate from the app. You don't need Swift for that. You will need a server (for example a cheap cloud VPS on Amazon EC2, Rackspace Cloud Servers, Microsoft Azure...) and you will have to create another application that runs on that server.
If it's just to pull data from a MySQL database, you can easily make that in PHP. Or you could use Node.js (which uses JavaScript: it's among the "trendiest" technologies at the moment), Ruby, Python, etc.For an example that uses PHP, you can check: https://stackoverflow.com/a/22367600/192024
To read the JSON data in your iOS app, then, you can use the builtin libraries: https://developer.apple.com/library/ios/DOCUMENTATION/Foundation/Reference/NSJSONSerialization_Class/index.html (it's available in Swift too)
I don't know what your app is doing, but if you want to ignore all the things with the backend (the server) you can always consider something like Parse Core and let somebody else take care of the backend.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
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.
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.
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.
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.
Simply put, the best way to go is for you to use a php web service with phone gap.
You can also go through android using PHP and android. This is a very good and simple way to go. Try the tutorial here
You may tray Xamarin (part of .Net) with the free version of Visual Studio Community and then interact with your PHP web-app. You can then compile the native Xamarin app (written in C#) to Android and iOS.