My background is in PHP but I have recently started developing an iOS app. I need to store and retrieve values in some sort of database (where I would usually use MySQL in PHP).
For example, supposing the app displayed a list of pubs in a town, the user would be able to choose their town and view a list of all the pubs. This would allow me to add/remove pubs on the app (by editing the database) without requiring an app update.
Is this something I can still use MySQL for, or are there other preferred methods when it comes to iOS development?
Yes, you can still use PHP and MySQL to do that.
The best solution is create a Web Service with PHP and MySQL as a backend.
You can expose web service and consume it from the app. You can even create web site to use the same web service (or database directly) so you can amend the database via website and all iOS users will see the changes on the app.
There is plenty of tutorial about this topic. This is a good one link
Related
I'm building a mobile project that needs to be in constant communication with a server and i need some information . I know how to build local apps but this is the first time that i'm building an app that requires external call to a server / authentication service .
I'm asking for guidance how to proceed and which services/servers to use.
What type of server/database do i need ?
I'm guessing i will be requiring an API service but no idea how to choose/make one.
I want to use azure services/database but i also don't want to be dependent on it. I want to have my own url that i send request to and interact with a server/db that i can later move to another host fairly easily.
I develop websites mostly and i'm familiar with php/laravel + Mysql but i think in this case it will be overkill to create a laravel app simply for the server backend .
The app will be mobile only so i don't expect to have a webpage for it . simply an external server/database where the data will be saved.
First i need an authentication service - where each user will register on the phone which will then be saved in my external server/database . Then when they need to login - they will input the login details on the phone , which will query the esternal server/database and if validated - get their details from the server.
First, you need to decide which kind of server communication you'll need. it's in real time and constant? then you'll need a websocket. It's in bursts when you need to send or get data? then you'll need some kind of webservice (REST, RPC, SOAP). Then you have to evaluate the user load you'll have. And finally, the human resources you'll have.
Based on your question, I think a REST webservice will be more than enough. You may:
-Create a REST service for every group of related resources. Example: the /user URL should handle the signup, login, logout and user update operations.
-Create a method for each one of those operations and handle them. Then, call the method from the REST service class.
-Depending on the amount of users and the technology you're using, create a server to handle the requests, or upload your REST project to a server (tomcat, for example).
-Create an app and consume the REST services from there.
There are tons of tech you can choose for these things. PHP allows creating REST services, I think. Java is a very good choice too, since you can use the same code in both server and android apps. Node.Js is pretty popular, too, since you don't need servers and uses NIO (althought java can do both things using jetty and also has multithreading); golang and scala both have superb performance (golang is a lot more easier to learn, though, and it has no need to use external webservers).
Hope this helps.
For mobile applications the best will be REST (representational state transfer),becouse is lightweight and flex to use in other technology. I had project which include REST and mobile app and web app and it working very well.
In this scenario, we usually will build a REST API service for client end. As you are familiar with Laravel, you can refer to http://www.programmableweb.com/news/how-to-build-restful-apis-using-php-and-laravel/how-to/2014/08/13#apiu for how to build a REST API service with Laravel. Also you can leverage other light 3rd part PHP frameworks to build REST API service.
You can create and develop the application on local and then deploy to Azure Web Apps. Please refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-web-php-get-started/ for more info.
And there several vendors provide MySQL services on Azure. ClearDB is a BaaS on Azure for MySQL. You also can use the VM to host your MySQL Service. E.G. MySQL by Bitnami and MySQL by Docker.
Currently building a hybrid app. using Ionic Framework with PHP for backend services
I am having a case where a user has got his profile in Web app and Mobile App as well.
If the user adds two stories as favourites (Its kind of a reading app) from his mobile app or Web app,how do I sync that?
Here are the scenarios:
1) User marks the stories favourites from web app and when I come online through mobile app, display it.
2) User marks the stories favourites from mobile app when he is offline(Now this will be stored in LocalDB). So again when he comes online sync with the server?
I know there are services like Firebase which provides syncing service.
But What If I would want to develop a Custom Syncing service on my own for my application? Is that an extremely complicated process?
If yes and it can be developed ,then how should I proceed ? A basic idea? What are the best practices that I should consider?
Any links would be appreciated?
I know some of the comments recommended CouchDB in combination with PouchDB. That is a much better solution than trying to implement your own synchronization service with MySQL.
However, since you're using Ionic Framework you can also use Couchbase. Take the following example application:
https://github.com/couchbaselabs/TodoLite-Ionic
If you chose this solution you would have three moving parts. You would be replacing MySQL with Couchbase Server and running the Couchbase Sync Gateway to orchestrate any data between the device and the server. You can still keep your PHP backend if you have a web version of your application as there is a PHP SDK for Couchbase.
Two write-ups on this can be found here:
http://blog.couchbase.com/using-couchbase-in-your-ionic-framework-application-part-1
http://blog.couchbase.com/using-couchbase-in-your-ionic-framework-application-part-2
In the long term, you're going to find NoSQL much more pleasant to work with when it comes to APIs and mobile than MySQL.
Can be useful to write a POST method on the backend that receives the data from your local from the app and some user data (session, access tokens and other thing you considered neceasary). On the body for the request you include the data needed to be synced. The backend takes the body. Parse it and rreturn a result (http code) Based on that you can decide if the app should delete the local data or only mark it as synced on the local database
We have a web-application(Loyalty platform for restaurants) developed in PHP. But most of these merchants dont have internet connection all the time. So, is there way to convert only merchant module into a desktop application so that merchant works stand alone and it syncs to web application whenever there is an internet connection.
Yes it is possible ,but not like a wizard job.
If you know only PHP than you can use Titanium ,and deploy Desktop App's.
You can use a local database ,an XML ,jSON or SQLite and on the first connection with internet you can clear the local database and update the Remote one.
I am working on a similar project and in my case I am following the below aproach.
Web Application is PHP and MySQL
Desktop Application is .net Application using SQL Lite
Windows Service checks for internet connection and syncs db in the background
In my case, my users can go offline for days or weeks and data was critical for me and I felt HTML 5 offline content was not the best option for this.
No. Designing a desktop PHP app is very different from designing a web PHP app and will require major amounts of rearchitecting.
Now having said that, it is possible to deploy a web server to the client's machine and have it run a web PHP app there. It will still require some rearchitecting to get the sync working though.
Develop a desktop application in .net or Java what ever you are familiar with and use some database like SQLite to save the data locally. When ever the user goes to online you need to connect to your online database and sync the data.
If there is possibility that same data can be updated by different users, then you have to plan on handling the conflicting scenarios like if a data record is updated at both end which data should be used. If there is no possibility to concurrent update then simply you will have to upload your data when user goes online.
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.
I want to build a phone app using phonegap that can access data on a mysql server that is backing a cakephp app. Can this be done, if yes then how can use phonegap to access data from a mysql server?
Yes you can!
You need too make the controllers of you cakephp to output views that can be interpreted by the javascript in your phonegap app. For a more detailed answer we need more information. i.e. what javascript framework do you want to use in the phonegap app?
Just to be aware, an app that is basically a web page will probably be rejected by Apple. Quoting from the Phonegap Faq:
Q. Can I just create an iPhone PhoneGap-based app that just loads my website?
A. You can, but as for Apple approving it, that's another matter, and they most likely won't. As a rule of thumb, if there is no Internet connection, you must at least load the UI (your views) without the corresponding data, and put an error notice to that effect. Therefore your app must have these views included in it. For a guideline, set your iPhone to Airplane Mode in the Settings, then load either the Maps, Weather, Youtube, ITunes or Facebook apps, and see what they do (have a "shell"). Apple is probably concerned about them approving your app based on your app description and functionality as promised by you, and then you turning around and changing it completely after approval to something undesirable.
Also see similar question: iPhone Phonegap based app load External website made of componentone