iOS app Update on new MySQL entry - php

I am trying to implement "passive-waiting" in an iOS app, connected to a MySQL database. The app needs to get information from the database, which is no problem, but what I can't figure out, is how i can get the MySQL database to somehow notify the app when a change occurs.
It could be implemented, by simple having the app constantly check the database asking for new entries, but that is not very efficient. Would be smarter if the app would only connect and ask the DB for data, when it KNOWS there is newly submitted data to fetch.
How can this be implemented?
Thank you

The concept you are looking for is called "Push notifications". Here is one of the tutorials I've found with a quick search: https://parse.com/tutorials/ios-push-notifications

Related

Why api is used when you can fetch data directly from database using sql query?

I am a newbie to the web application. I just understood what is an api and why it is used by reading some online blog. But I was wondering why to use an api to fetch data(or insert data) when you can directly fetch data from database using PHP and mysql.(I am sorry if this question sounds stupid.) An answer with example would be great. Thanks
API are used to make communications more secure. With an API you can add encryption, different users and roles and a lot more. With MySQL you can not do that on the same level.
Future more, MySQL is a service, and if you work directly with it, it has to be open on a Port. Here you can not add not as well protection as you can on a Webserver.
An API can also add some logic. Maybe you want to control the input given by a request to it. Or maybe you want to have some additional calculations going on, before you make any INSERT or UPDATE to the database. This can help you to have your database clean.
If the System where the database and the API is located at, decides to change the database from lets say MySQL to PostgreSQL or anything else, every service connecting to it will have to change its code to make it work with the new environment.
So, an API can be more secure and has some standard everyone can rely on, even if the APIs background changes.

Multiplayer Android Game-doubts about database online

I developed a stupid game in eclipse (not using any particular library such as libgdx, only with "normal code").
I have some doubts about the multiplayer and databases online. In my game I haven't developed yet a database. So i thought I should have create a database online with mysql and connect to my android app. If so i would create users stored in my mysql online and the parse them with a json parser connecting to mysql trough some php based bridges.
Then i searched for android multiplayer and i found out that a more efficient way to create login user is using google+ login offered by google.
Gived the fact that my database isn't only a way to let user log in but it is also a way to store tha stats about their matches, If i wanted to use g+ login, should I have a mysql database connecting to my app to store other data, or in a way that i actually ignore google provides these things?
The other doubt is about multiplayer: what i should do to implement it?
Once the g+ login is implemented, then what should I implement?
Matches between users are managed and stored completely by google or not?
Should I have to add these informations in my DB online (if at the point one the DB is needed).
Sorry for my bad english.
Hope you can help me.
Thank you.

What is the best way to notify all connected clients about changes on the server?

I am working on a small client-server project. The front-end is an Android application and the back-end is written in PHP. There is going to be several clients (10+-) that are going to manipulate the data in the server database. Those changes should be immediately reflected to all connected devices.
My question is, should I use sockets so the server will send the updated data to all connected devices once something gets updated or should rather a device be responsible for checking for updates on the server? If so, what would be the best way to do it? Should each row in the database have an update times-tamp and I always fetch all rows whose time-stamp is bigger than the time-stamp of the last update on the device.
I think push notification the best solution for this task. And of course need to have timestamp of last changes in database and android client.

android multiplayer, database connectivity api

am thinking to make a android multiplier game. Am looking for API which can connect to my database and access data continuously. In my mind i have a idea about this. I know how to connect to database with php and access data. But the problem is i cant figure out how to access data continuously until game runs. If you have a new idea please share it with me. Or else suggest me some API's or some methods or some links which may be useful. Any help will be appreciated.

How to display the values into Android Client from MySQL using PHP Web Service

I have question regarding on how to display the values into the Android Client from online database in MySQL using the PHP Web Service. The idea is such that initially when the activity is displayed, the first record must be displayed in the textview. There would be a button called Next which would display the next record and move the cursor to the next record in the database. My question is that the move to next record logic should be written in which place? That means should I write the move-to-next-record code in the Android client or should I write in the PHP code?
For the basic understanding of how to connect to an online db in Android Client I had referred to the question in this forum itself:
Connect to Remote DB which gave me a good understanding on how to connect to remote db. But here my idea is kind of different which is event based and has to move to the next record and display in the textview. Any hints and suggesstions? Very grateful if you help me! Thank you.
It is really bad idea to connect directly to database. AFAIK, you can create a PHP/MySQL Service to return data in such a format that clients can parse, like popular JSON.
Have a look at this: http://blog.sptechnolab.com/2011/02/10/android/android-connecting-to-mysql-using-php/
Hope it helps!

Categories