From 8ac767764844e26e3e9fc83c812912697c7572ca Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko Date: Tue, 27 Feb 2024 04:24:07 +0700 Subject: [PATCH] ios: remove passcodes if app was reinstalled (#3841) * ios: remove passwords if app was reinstalled * change instead of delete * Revert "change instead of delete" This reverts commit 1195ee5b3088537b368e4547cb0ec1bdfe0a11da. * update name and comments --------- Co-authored-by: Avently Co-authored-by: Evgeny Poberezkin --- apps/ios/Shared/AppDelegate.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/ios/Shared/AppDelegate.swift b/apps/ios/Shared/AppDelegate.swift index 24c0eeb605..7204625ad4 100644 --- a/apps/ios/Shared/AppDelegate.swift +++ b/apps/ios/Shared/AppDelegate.swift @@ -16,6 +16,7 @@ class AppDelegate: NSObject, UIApplicationDelegate { application.registerForRemoteNotifications() if #available(iOS 17.0, *) { trackKeyboard() } NotificationCenter.default.addObserver(self, selector: #selector(pasteboardChanged), name: UIPasteboard.changedNotification, object: nil) + removePasscodesIfReinstalled() return true } @@ -127,6 +128,19 @@ class AppDelegate: NSObject, UIApplicationDelegate { BGManager.shared.receiveMessages(complete) } + private func removePasscodesIfReinstalled() { + // Check for the database existence, because app and self destruct passcodes + // will be saved and restored by iOS when a user deletes and re-installs the app. + // In this case the database and settings will be deleted, but the passcodes won't be. + // Deleting passcodes ensures that the user will not get stuck on "Opening app..." screen. + if (kcAppPassword.get() != nil || kcSelfDestructPassword.get() != nil) && + !UserDefaults.standard.bool(forKey: DEFAULT_PERFORM_LA) && !hasDatabase() { + _ = kcAppPassword.remove() + _ = kcSelfDestructPassword.remove() + _ = kcDatabasePassword.remove() + } + } + static func keepScreenOn(_ on: Bool) { UIApplication.shared.isIdleTimerDisabled = on }