azamsharp
azamsharp

Reputation: 20076

How do I update a database I distribute with an iOS app, without updating the app itself?

I am building an application where the users can download cooking recipes. Each recipe is accompanied with image. The db will be Sqlite and it will be deployed locally on the users device. I plan to put all the images inside the "Supported Files" folder which will be used by the local database.

My question is that how will I update the images without having to push out a new version. Let's say I add a new recipe to my server database and I want users to have that recipe how will I accomplish that?

Upvotes: 0

Views: 596

Answers (2)

Kevin
Kevin

Reputation: 56089

Have your app query the server once in a while to see whether any of the pictures have changed since it last updated. I'd suggest having the app send a list of filenames with their mtimes, and have the server send back a list of stale files. Your app can then fetch the new files, replacing the old ones.

Upvotes: 0

Richard J. Ross III
Richard J. Ross III

Reputation: 55573

You need to have a API to request the current recipes version, that you can use to check for updates. Example:

 http://api.mysite.com/isCurrentVersion?v=0.0.5

That can return a HTTP response code that tells you to update the images / database you have cached, or you can simply can use php to echo a number of the current version, and do string matching client side, like this:

 NSString *downloadedVersion = [[NSUserDefaults standardUserDefaults] stringForKey:@"version"];
 NSString *serverVersion = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://api.mysite.com/currentVersion"]];

 if ([downloadedVersion caseInsensitiveCompare:serverVersion])
      // download the new version

Server code:

 <?php
    echo "current_version_number" 
 ?>

Upvotes: 1

Related Questions