Reputation: 1258
I am developing an application which have some pre loaded app resources that can be changed dynamically by user or admin, I have to put these app resources in document directory of my app so that it will not make me to update application on itunes.
Problem that I am facing that i have to download all the app resources from web server on local device when application launches for the first time.
I am seeking for the best method for fetching all my app resources and keep it updated? Please help me!
Actually, The problem is that I have thousands of resources like images, html and css files that have to be downloaded, and end user might feel problem in refreshing or maintain the data on server. Is there any file transfer protocol (ftp) library in iOS available to download the data and update? or any other method?
Upvotes: 1
Views: 2031
Reputation: 4712
1) First time, take all the records from server along with the server date(check date parameter, if null
then server passes all records i.e. first time app is launched).
2) Store that date in NSUserDefaults
.
3) Second time pass that date while request
, if date is not null(request is not first time).
4) Server checks the updated records(records greater than the date which you passed).
NSString *strTodaysDate = @"";
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SyncDone"] != nil)
{
//If sync all data is done first time, then pass server date else pass empty date parameter.
strTodaysDate = [NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] valueForKey:@"SyncDate"]];
} //call web service with strTodaysDate as a parameter.
Upvotes: 2
Reputation: 761
You can update data of your by calling web service from application delegate from this method
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
//make call to web service and save it in your document directory
}
Upvotes: 1
Reputation: 1433
You need to send simple request from application everytime application launches, which will ask server about updates. If your content on server was updated then you need to reload your content in application.
Of course your server must know if there was some changes in content. You can track changes time on server and latest content update time in application.
Upvotes: 1