diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 8b1355f59..1b40da511 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -668,6 +668,29 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { [self updateBarButtonItems]; [self applyTheme]; + + NSString *buildNumberAsString = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]; + NSInteger buildNumber = buildNumberAsString.integerValue; + NSUserDefaults *userDefaults = NSUserDefaults.standardUserDefaults; + BOOL didUpdateForMainnet = [userDefaults boolForKey:@"didUpdateForMainnet"]; + if ((buildNumber == 8 || buildNumber == 9) && !didUpdateForMainnet) { + NSString *title = NSLocalizedString(@"Update Required", @""); + NSString *message = NSLocalizedString(@"This version of Loki Messenger is no longer supported. Please press OK to reset your account and migrate to the latest version.", @""); + UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [ThreadUtil deleteAllContent]; + [SSKEnvironment.shared.identityManager clearIdentityKey]; + [LKAPI clearRandomSnodePool]; + [LKAPI stopLongPolling]; + UIViewController *rootViewController = [[OnboardingController new] initialViewController]; + OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:rootViewController]; + navigationController.navigationBarHidden = YES; + UIApplication.sharedApplication.keyWindow.rootViewController = navigationController; + [userDefaults setBool:YES forKey:@"didUpdateForMainnet"]; + }]]; + [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { /* Do nothing */ }]]; + [self presentAlert:alert]; + } } - (void)applyDefaultBackButton diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index a46f26526..f969fdb60 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2603,3 +2603,5 @@ "Clear All Data" = "Clear All Data"; "Are you sure you want to clear all your data? This will delete your entire account, including all conversations and your personal key pair." = "Are you sure you want to clear all your data? This will delete your entire account, including all conversations and your personal key pair."; "Cancel" = "Cancel"; +"Update Required" = "Update Required"; +"This version of Loki Messenger is no longer supported. Please press OK to reset your account and migrate to the latest version." = "This version of Loki Messenger is no longer supported. Please press OK to reset your account and migrate to the latest version.";