Skip to content
This repository has been archived by the owner on Sep 11, 2018. It is now read-only.

Commit

Permalink
Change the nag alert to show once a week and add a helpful link to th…
Browse files Browse the repository at this point in the history
…e App Store
  • Loading branch information
rbruels committed Jan 4, 2011
1 parent 7849836 commit a2bbf4a
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions Classes/iRedditAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "Constants.h"
#import "LoginController.h"

#define SEEN_DEPRECATED_NOTICE @"ireddit-free-seen-deprecated"
#define SEEN_DEPRECATED_NOTICE_TIMESTAMP @"ireddit-free-seen-deprecated"

extern NSMutableArray *visitedArray;

Expand All @@ -40,19 +40,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
//register defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

#ifdef DEPRECATED_FREE
if(![defaults boolForKey:SEEN_DEPRECATED_NOTICE])
{
UIAlertView *deprecatedAlert = [[UIAlertView alloc] initWithTitle:@"Goodbye, iReddit Free!"
message:@"iReddit Free will no longer be supported or updated. Please download the new iReddit for FREE from App Store to keep up with future updates!"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[deprecatedAlert show];
[deprecatedAlert release];
}
#endif

[defaults registerDefaults:
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], showStoryThumbnailKey,
Expand Down Expand Up @@ -98,9 +85,36 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
[self loadRandomData];
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
#ifdef DEPRECATED_FREE
NSTimeInterval periodOfBlessedSilence = 60 * 60 * 24 * 7; // if the user hasn't seen the alert for 1 week, show it again
NSTimeInterval lastSeenDeprecatedAlertTime = [[NSUserDefaults standardUserDefaults] doubleForKey:SEEN_DEPRECATED_NOTICE_TIMESTAMP];
NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];
if(currentTime - lastSeenDeprecatedAlertTime > periodOfBlessedSilence)
{
UIAlertView *deprecatedAlert = [[UIAlertView alloc] initWithTitle:@"Goodbye, iReddit Free!"
message:@"iReddit Free will no longer be supported or updated. Please download the new iReddit for FREE from App Store to keep up with future updates!"
delegate:self
cancelButtonTitle:@"Later"
otherButtonTitles:@"Download", nil];
[deprecatedAlert show];
[deprecatedAlert release];
}
#endif
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:SEEN_DEPRECATED_NOTICE];
// save the last timestamp
[[NSUserDefaults standardUserDefaults] setDouble:[NSDate timeIntervalSinceReferenceDate] forKey:SEEN_DEPRECATED_NOTICE_TIMESTAMP];

if(buttonIndex != alertView.cancelButtonIndex)
{
// take them to the store if requested
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.com/apps/iReddit"]];
}

}

- (void)deviceDidShake:(NSNotification *)notif
Expand Down

0 comments on commit a2bbf4a

Please sign in to comment.