From 49a2a10cc651b952f625717add10e19c6c07e316 Mon Sep 17 00:00:00 2001 From: Igor Khmurets Date: Tue, 19 Aug 2014 12:09:27 +0300 Subject: [PATCH] [ios] 17th august promo logic removed --- .../Maps/Classes/LocalNotificationManager.h | 2 - .../Maps/Classes/LocalNotificationManager.mm | 44 ------------------- iphone/Maps/Classes/MapViewController.mm | 28 ------------ iphone/Maps/Classes/MapsAppDelegate.mm | 9 +--- 4 files changed, 1 insertion(+), 82 deletions(-) diff --git a/iphone/Maps/Classes/LocalNotificationManager.h b/iphone/Maps/Classes/LocalNotificationManager.h index 5ca2cc6c11..afda85d46b 100644 --- a/iphone/Maps/Classes/LocalNotificationManager.h +++ b/iphone/Maps/Classes/LocalNotificationManager.h @@ -9,6 +9,4 @@ - (void)showDownloadMapAlertIfNeeded; - (void)processNotification:(UILocalNotification *)notification; -- (void)schedulePromoNotification; - @end diff --git a/iphone/Maps/Classes/LocalNotificationManager.mm b/iphone/Maps/Classes/LocalNotificationManager.mm index d4fee619cc..cef0c5efcc 100644 --- a/iphone/Maps/Classes/LocalNotificationManager.mm +++ b/iphone/Maps/Classes/LocalNotificationManager.mm @@ -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 diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 87a8d6a9ac..76e609b8c9 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -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 diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 76313fab1f..04632dd63d 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -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