Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change the nag alert to show once a week and add a helpful link to th…

…e App Store
  • Loading branch information...
commit a2bbf4a9a6391d9b6f045b991af5b356d5659d37 1 parent 7849836
Ryan Bruels rbruels authored

Showing 1 changed file with 29 additions and 15 deletions. Show diff stats Hide diff stats

  1. +29 15 Classes/iRedditAppDelegate.m
44 Classes/iRedditAppDelegate.m
@@ -13,7 +13,7 @@
13 13 #import "Constants.h"
14 14 #import "LoginController.h"
15 15
16   -#define SEEN_DEPRECATED_NOTICE @"ireddit-free-seen-deprecated"
  16 +#define SEEN_DEPRECATED_NOTICE_TIMESTAMP @"ireddit-free-seen-deprecated"
17 17
18 18 extern NSMutableArray *visitedArray;
19 19
@@ -40,19 +40,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
40 40 //register defaults
41 41 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
42 42
43   -#ifdef DEPRECATED_FREE
44   - if(![defaults boolForKey:SEEN_DEPRECATED_NOTICE])
45   - {
46   - UIAlertView *deprecatedAlert = [[UIAlertView alloc] initWithTitle:@"Goodbye, iReddit Free!"
47   - 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!"
48   - delegate:self
49   - cancelButtonTitle:nil
50   - otherButtonTitles:@"OK", nil];
51   - [deprecatedAlert show];
52   - [deprecatedAlert release];
53   - }
54   -#endif
55   -
56 43 [defaults registerDefaults:
57 44 [NSDictionary dictionaryWithObjectsAndKeys:
58 45 [NSNumber numberWithBool:YES], showStoryThumbnailKey,
@@ -98,9 +85,36 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
98 85 [self loadRandomData];
99 86 }
100 87
  88 +- (void)applicationDidBecomeActive:(UIApplication *)application
  89 +{
  90 +#ifdef DEPRECATED_FREE
  91 + NSTimeInterval periodOfBlessedSilence = 60 * 60 * 24 * 7; // if the user hasn't seen the alert for 1 week, show it again
  92 + NSTimeInterval lastSeenDeprecatedAlertTime = [[NSUserDefaults standardUserDefaults] doubleForKey:SEEN_DEPRECATED_NOTICE_TIMESTAMP];
  93 + NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];
  94 + if(currentTime - lastSeenDeprecatedAlertTime > periodOfBlessedSilence)
  95 + {
  96 + UIAlertView *deprecatedAlert = [[UIAlertView alloc] initWithTitle:@"Goodbye, iReddit Free!"
  97 + 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!"
  98 + delegate:self
  99 + cancelButtonTitle:@"Later"
  100 + otherButtonTitles:@"Download", nil];
  101 + [deprecatedAlert show];
  102 + [deprecatedAlert release];
  103 + }
  104 +#endif
  105 +}
  106 +
101 107 - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
102 108 {
103   - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:SEEN_DEPRECATED_NOTICE];
  109 + // save the last timestamp
  110 + [[NSUserDefaults standardUserDefaults] setDouble:[NSDate timeIntervalSinceReferenceDate] forKey:SEEN_DEPRECATED_NOTICE_TIMESTAMP];
  111 +
  112 + if(buttonIndex != alertView.cancelButtonIndex)
  113 + {
  114 + // take them to the store if requested
  115 + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms-apps://itunes.com/apps/iReddit"]];
  116 + }
  117 +
104 118 }
105 119
106 120 - (void)deviceDidShake:(NSNotification *)notif

0 comments on commit a2bbf4a

Please sign in to comment.
Something went wrong with that request. Please try again.