How to install an update programatically?

Asked by keith alperin

My app uses [[SUUpdater sharedUpdater] checkForUpdateInformation] to check for updates and then presents it's own UI to show that an update is available. Is there a standard way for me to actually install the update from my own UI? I can do it if i make SUBasicUpdateDriver public and rebuild sparkle, but i'd prefer to use something that works out of the box.

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Solved by:
Andy Matuschak
Solved:
Last query:
Last reply:
Revision history for this message
Best Andy Matuschak (andymatuschak) said :
#1

Interesting problem. I think that you can call setAutomaticallyDownloadsUpdates on SUUpdater in such a way as to make that work (ie: set it to yes when the user chooses to update through your UI, then tell it to update in the background). Though it's a little hacky.

Revision history for this message
keith alperin (keith-heliumfoot) said :
#2

Thanks Andy, that's a good out-of-the box solution and works perfectly. What would you think about an installUpdate method on SUUpdater that would directly delegate to the driver?

Revision history for this message
Andy Matuschak (andymatuschak) said :
#3

Hm. Passing the delegate the path of the update archive? Or the folder in which the update was extracted? If the former, then they have to duplicate the extraction functionality; if the latter, then the client has to figure out where in the folder the update is. It's an interesting idea but requires more thought.

Revision history for this message
Cranky (tblanchard) said :
#4

I also want to handle all of my own UI. I ended up squashing a method with a category to get the desired behavior. Evil code below.

// HACK HACK HACK HACK all these interfaces are meant to be private
// Shut up the compiler about superclass
@interface SUAutomaticUpdateDriver : NSObject
{}

-(void)installUpdate;

@end

@class SUUnarchiver;

@interface SUAutomaticUpdateDriver (QCOverrides)

- (void)unarchiverDidFinish:(SUUnarchiver *)ua;

@end

@implementation SUAutomaticUpdateDriver (QCOverrides)

// the usual implementation presents an alert with three buttons - we don't want to give the user a choice - install away!
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
    [self installUpdate];
}

@end