From 47616814703f1329629dc106315d4293b1ad42ec Mon Sep 17 00:00:00 2001 From: Jon Petersson Date: Thu, 17 Oct 2024 16:25:24 +0200 Subject: [PATCH] Fix app going into blocked state on first-time installs --- ios/CHANGELOG.md | 3 +++ ios/MullvadVPN/AppDelegate.swift | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index 68b62affefc7..aee8e0a84f96 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -26,6 +26,9 @@ Line wrap the file at 100 chars. Th - Replace the draft key encapsulation mechanism Kyber (round 3) with the standardized ML-KEM (FIPS 203) dito in the handshake for Quantum-resistant tunnels. +### Fixed +- Fix app going into blocked state on first-time installs. + ## [2024.8 - 2024-10-14] ### Added - Add a new access method that uses the encrypted DNS proxy to reach our API. diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index 5010f71ebd8b..6314dc62ac74 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -519,7 +519,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD } } - /// Returns an operation that acts on two conditions: + /// Returns an operation that acts on the following conditions: + /// 1. If the app has never been launched, preload with default settings. + /// - or - /// 1. Has the app been launched at least once after install? (`FirstTimeLaunch.hasFinished`) /// 2. Has the app - at some point in time - been updated from a version compatible with wiping settings? /// (`SettingsManager.getShouldWipeSettings()`) @@ -527,7 +529,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD /// compatible, thus triggering a settings wipe. private func getWipeSettingsOperation() -> AsyncBlockOperation { AsyncBlockOperation { - if !FirstTimeLaunch.hasFinished, SettingsManager.getShouldWipeSettings() { + let appHasNeverBeenLaunched = !FirstTimeLaunch.hasFinished && !SettingsManager.getShouldWipeSettings() + let appWasLaunchedAfterReinstall = !FirstTimeLaunch.hasFinished && SettingsManager.getShouldWipeSettings() + + if appHasNeverBeenLaunched { + try? SettingsManager.writeSettings(LatestTunnelSettings()) + } else if appWasLaunchedAfterReinstall { if let deviceState = try? SettingsManager.readDeviceState(), let accountData = deviceState.accountData, let deviceData = deviceState.deviceData {