I am new in mobile development and I have a project to do and I spent the whole past days searching for solution to a problem until I got lost so I hope I can find the final answer here.
I have a server (php & MySQL DB) and developing a mobile app in iOS + Android that retrieve data from the server. The mobile app should take the data from the server in the first run and save it in the phone so whenever it run again it take the stored data.
The server should notify the app "without the user being aware" whenever a change made so that the app can go and update the data immediately.
I thought about using webservice (probably REST with RestKit) or applying sort of timestamps on the server records, which are all not the problem.
My problem is that I can't find a way to let the server itself notify the app about the changes whenever a change happen and allowing the app then to update the new data. I thought about using push notifications but - specially in iOS - it can't be hidden from the users.
So is there a possible way to do it? is it complex? does it worth? other suggestions?
As I said I am new so maybe my thinking wrong so sorry in that case, and I searched through the questions and couldn't figure out an answer for my question.
At least in iOS, a solution would be to use Apple Push Notifications. If you don't want to be intrusive and want it to be as transparent as possible, you can define what kind of "notifications" signals you want, like this:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
As for the background process, I don't think you would be able to do that. Apple is very strict in what you can do in background (not background thread, but background as a working process while you are not in the application). What I would advise, would be using a notification badge, so the user would know that there is something new, and when he entered the application you could start your update.
I have to agree with Yase:
Why update the data if the user is not aware of it?.
You should always make it as user friendly as possible. Not letting your user know that the application might consume resources is bad, in my opinion. Imagine that you are updating 2mb of information and the user is on 3G...
Can you explain what you are trying to do? The classic idiom here would be to update the data when the application is started (you can use the cached version is it's still up-to-date and if the user has no connection) Why update the data if the user is not aware of it?
I'm not sure if I am following your question right but it sounds like you want the server to be aware that changes have been made and then notify the user of those changes.
Why not run a cron job to check the server on whatever timed cycle you want and then either send a push notification to the user (on iOS)
I've little Android experience but it seems stickier to do push notifications on those devices. (I'm sure someone will correct me on that soon enough though : D )
This might help:
It is not possible on iOS without the user being aware of the app - the only way you can update the application data from server side is if...
In both cases the user is aware of that the application is running. What you can do is that you update the data in the background while the user is using the app. You can use push messages to make the user open the app. But that's it.
On Android there may be some more possibilities if you let the application run a background service, however don't forget that users will remove your app if it is draining batteries etc.
For application data update you should check the version of your data on server. The best way for this is to make your app to ask your server every time user launches the application: user launches app -> app asks server if there is new data in RESTful API style -> server response that yes/no -> if there is new data, application loads it to the device.