Application Expiration


/ Published in: Objective C
Save to your folder(s)

Implement this in YourAppController delegate class to check for an expiration date when the app is first initialized.


Copy this code and paste it in your HTML
  1. - (id) init
  2. {
  3. self = [super init];
  4. if (self != nil) {
  5. // If past expiration date, then pop up a dialog that says
  6. // the user needs to download a new version, quit the app, and
  7. // load the website for new downloads
  8.  
  9. NSDate *now = [NSDate date];
  10. NSDate *expire = [NSDate dateWithNaturalLanguageString:@"4:30pm May 19, 2009"];
  11.  
  12. if ([now timeIntervalSinceReferenceDate] > [expire timeIntervalSinceReferenceDate]){
  13. NSLog(@"Beta Expired");
  14. if (NSRunAlertPanel(@"This beta of App has expired.",
  15. @"Please download a new version from\nhttp://appwebsite.com.",
  16. @"Go to the Download Page", @"Maybe Later", nil)) {
  17. [self openURL:@"http://appwebsite.com/"];
  18. }
  19. [[NSApplication sharedApplication] terminate:self];
  20. }
  21. }
  22. return self;
  23. }
  24.  
  25. - (void)openURL:(NSString *)url {
  26. // open URL in browser
  27. [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:url]];
  28. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.