1

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?

Usman Awan
  • 1,208
  • 2
  • 13
  • 30
  • Well, you can make a request to your server to fetch all the required resource while launching your application. – Praveen-K Mar 11 '13 at 08:40

3 Answers3

2

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. 
Girish
  • 4,692
  • 4
  • 35
  • 55
  • Thanks for your answer, so web service will send any xml or json in reply? – Usman Awan Mar 11 '13 at 09:10
  • Yes server response contains XML/JSON, it depends on ur parsing. – Girish Mar 11 '13 at 09:12
  • Every table on server side, contains two date fields, LastModified & Created date. When any change occured in any row, then change is LastModifiedDate & compare LastModifiedDate withe the date which we passed as parameter to the web service. – Girish Mar 11 '13 at 09:14
  • Actually, The problem is that I have thousands for static 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? – Usman Awan Mar 11 '13 at 09:59
  • If the resources are static, then directly add it into the app. Bcz it takes lot of time, if u take it from server. – Girish Mar 11 '13 at 10:14
  • Sorry, These resources can be changed.. so i can't put directly into the app. user can change any image or html page if he wants too.The requirement is that all the resources should run from app locally...not from server, so that is why i need to have to download all the resources from the server when application launches for the first time.. – Usman Awan Mar 11 '13 at 10:19
  • So u needs to write different web services for different web service call. i.e. If user goes into info page, then call web service to get the html file info page and same for others. – Girish Mar 11 '13 at 10:28
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/25948/discussion-between-usman-awan-and-girish) – Usman Awan Mar 11 '13 at 10:55
1

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.

Artem Shmatkov
  • 1,434
  • 5
  • 22
  • 41
  • Thanks for your answer, so i have to create some xml or json on server for maintaining version control? But it will be a very hetic for user to maintain the xml or json manually? – Usman Awan Mar 11 '13 at 08:55
  • One more question to I have to download files one by one from server or is there any other way to fetch all files at same time? – Usman Awan Mar 11 '13 at 08:57
  • User no need to know anything about realization. You can pass to application simply `YES` or `NO`, and then load content automatically or ask users if whey want to load update. – Artem Shmatkov Mar 11 '13 at 08:58
  • You can load archive - zip or something else, and then unzip it on device using some library. – Artem Shmatkov Mar 11 '13 at 08:59
  • Actually, The problem is that I have many 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? – Usman Awan Mar 11 '13 at 10:21
  • Thanks for your help guys.. really solved my problem..I got stuck with downloading my resources.. no i am downloading my resource via FTP server for the first time when application will be launch. – Usman Awan Mar 13 '13 at 19:01
1

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

}

alok srivastava
  • 761
  • 8
  • 19