[ios] 17th august promo logic removed

This commit is contained in:
Igor Khmurets 2014-08-19 12:09:27 +03:00 committed by Alex Zolotarev
parent 661e4bca5f
commit 49a2a10cc6
4 changed files with 1 additions and 82 deletions

View file

@ -9,6 +9,4 @@
- (void)showDownloadMapAlertIfNeeded;
- (void)processNotification:(UILocalNotification *)notification;
- (void)schedulePromoNotification;
@end

View file

@ -9,7 +9,6 @@
#import "UIKitCategories.h"
#define DOWNLOAD_MAP_ACTION_NAME @"DownloadMapAction"
#define PROMO_ACTION_NAME @"PromoAction"
#define FLAGS_KEY @"DownloadMapNotificationFlags"
#define SHOW_INTERVAL (6 * 30 * 24 * 60 * 60) // six months
@ -135,49 +134,6 @@ typedef void (^CompletionHandler)(UIBackgroundFetchResult);
TIndex const index = TIndex([ui[@"Group"] intValue], [ui[@"Country"] intValue], [ui[@"Region"] intValue]);
[self downloadCountryWithIndex:index];
}
else if ([ui[@"Action"] isEqualToString:PROMO_ACTION_NAME])
{
[[Statistics instance] logEvent:@"'Promo' Notification Clicked"];
[self performAfterDelay:0.3 block:^{
[[UIApplication sharedApplication] openProVersionFrom:@"ios_promo_notif"];
}];
}
}
- (void)schedulePromoNotification
{
if (GetPlatform().IsPro())
return;
UIApplication * application = [UIApplication sharedApplication];
if ([application canOpenURL:[NSURL URLWithString:MAPSWITHME_PREMIUM_LOCAL_URL]])
return;
for (UILocalNotification * notification in application.scheduledLocalNotifications)
{
if ([notification.userInfo[@"Action"] isEqualToString:PROMO_ACTION_NAME])
return;
}
NSDateComponents * components = [[NSDateComponents alloc] init];
[components setYear:2014];
[components setMonth:8];
[components setDay:17];
[components setHour:12];
NSDate * date = [[NSCalendar currentCalendar] dateFromComponents:components];
if ([date timeIntervalSinceNow] > 0)
{
UILocalNotification * notification = [[UILocalNotification alloc] init];
notification.fireDate = date;
notification.alertBody = NSLocalizedString(@"pro_version_is_free_today", nil);
notification.soundName = UILocalNotificationDefaultSoundName;
notification.userInfo = @{@"Action" : PROMO_ACTION_NAME};
[application scheduleLocalNotification:notification];
[[Statistics instance] logEvent:@"'Promo' Notification Scheduled"];
}
}
- (void)showDownloadMapAlertIfNeeded

View file

@ -572,34 +572,6 @@
[self.buyButton setTitle:proText forState:UIControlStateNormal];
}
#endif
[self showPromoAlertIfNeeded];
}
- (BOOL)dateIsInPromoTime:(NSDate *)date
{
NSCalendar * calendar = [NSCalendar currentCalendar];
NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour;
NSDateComponents * comp = [calendar components:unit fromDate:date];
return (comp.year == 2014) && (comp.month == 8) && ((comp.day == 17 && comp.hour >= 2) || (comp.day == 18 && comp.hour <= 22));
}
- (void)showPromoAlertIfNeeded
{
NSUserDefaults * userDefaults = [NSUserDefaults standardUserDefaults];
NSString * alertKey = @"PromoAlertShowed";
if ([userDefaults boolForKey:alertKey])
return;
if ([self dateIsInPromoTime:[NSDate date]] && [self dateIsInPromoTime:[AppInfo sharedInfo].firstLaunchDate])
{
[userDefaults setBool:YES forKey:alertKey];
[userDefaults synchronize];
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"maps_me_is_free_today_ios", nil) message:NSLocalizedString(@"maps_me_is_free_today_facebook_post_ios", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"no_thanks", nil) otherButtonTitles:NSLocalizedString(@"share", nil), nil];
alertView.tag = ALERT_VIEW_PROMO;
[alertView show];
}
}
- (void)viewDidAppear:(BOOL)animated

View file

@ -132,9 +132,6 @@ void InitLocalizedStrings()
[application setMinimumBackgroundFetchInterval:(6 * 60 * 60)];
LocalNotificationManager * notificationManager = [LocalNotificationManager sharedManager];
#ifdef OMIM_LITE
[notificationManager schedulePromoNotification];
#endif
if (launchOptions[UIApplicationLaunchOptionsLocalNotificationKey])
[notificationManager processNotification:launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]];
else
@ -145,11 +142,7 @@ void InitLocalizedStrings()
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
LocalNotificationManager * notificationManager = [LocalNotificationManager sharedManager];
#ifdef OMIM_LITE
[notificationManager schedulePromoNotification];
#endif
[notificationManager showDownloadMapNotificationIfNeeded:completionHandler];
[[LocalNotificationManager sharedManager] showDownloadMapNotificationIfNeeded:completionHandler];
}
- (void)applicationWillTerminate:(UIApplication *)application