Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expire a Mac OSX App within a certain timeframe and ask the user to update

Tags:

macos

cocoa

What's the recommended way to expire a beta Mac OSX app within a certain timeframe (i.e., 14 days) and then ask the user to update (in Cocoa)?

Do I just do date calculations every time the user launches the app? Also, is there a way to enable to updating using the Sparkle framework if the timeframe has expired?

Thanks

like image 323
James Avatar asked Oct 21 '12 00:10

James


1 Answers

I think for a beta that will definitely expire on a given date, you can just hardcode that date. Then you can compare like:

NSDate* expirationDate = [NSDate dateWithString: @"2012-03-24 10:45:32 +0600"];
if ([expirationDate compare:[NSDate date]] == NSOrderedAscending) {
    //is expired -> present update recommendation
}

If you want to be flexible with the date you could for example create a .txt file on your server wich contains a date-string. That could be easily loaded with:

NSString* dateString = [NSString stringWithContentsOfURL:myURL encoding:NSUTF8StringEncoding error:NULL];
NSDate* expirationDate = [NSDate dateWithString: dateString];

It sure would be nice, if you automatically present a sparkle update prompt. You can turn off automatic update checking (see: https://github.com/andymatuschak/Sparkle/wiki/make-preferences-ui ) and then, when the beta time is expired, manually perform an update check and/or reactivate the auto checking. (see: https://github.com/andymatuschak/Sparkle/wiki/customization )

like image 143
codingFriend1 Avatar answered Sep 22 '22 10:09

codingFriend1