How to check for server side update in iPhone application Web service request
I have kind of Listing application for iPhone application, which always calling a web service to my php server and fetching the data and displaying it onto iPhone screen.
Now, the thing to consider in this scenario is, my iPhone application everytime requesting on the server and fetching the data.
But now my requirement is like I want to replace following set of actions with above one :
-> Everytime when my application is launched in iP开发者_JAVA百科hone, it should check for the new data at the server`.
-> And if server replies "true" then only my iPhone application will made a request to fetch the data.
-> In case of "false", my iPhone application will display the data which is already cached in local phone memory.
Now to implement this scenario at server side (which has php, mysql), I am planning with the following solution :
Table : tblNewerData
id newDataFlag
== ============
1 true
Trigger : tgrUpdateNewData
Above trigger will update the tblNewerData -> newDataFlag field on Insert case of my main table.
And every time my iPhone app will request for tblNewerData->newDataFlag field, and if it found true then only it will create new request, and if it founds false then the cached version of data will be displayed.
So, I want to know that, is it the correct way to do so ? or else any other smart option available ?
Thanks in advance.
You should consider making the field a counter instead. Every time any change is made to your database, the counter is increased.
Now when the iPhone connects, it will compare that current counter with the counter from the previous fetch. If the counter has changed, it will fetch updated data.
精彩评论