fix: use a notification instead of an alert for force close

This commit is contained in:
naturecodevoid
2023-04-16 09:29:12 -07:00
parent f519d22d81
commit ee5ddd4264

View File

@@ -154,29 +154,14 @@ final class InstallAppOperation: ResultOperation<InstalledApp>
if installedApp.storeApp?.bundleIdentifier == Bundle.Info.appbundleIdentifier { if installedApp.storeApp?.bundleIdentifier == Bundle.Info.appbundleIdentifier {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) { DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
if installing { if installing {
print("We are still installing after 3 seconds") print("We are still installing after 3 seconds, requesting notification and then closing")
let alert = UIAlertController(title: "Finish Refresh", message: "To finish refreshing, SideStore must force close itself. Please reopen SideStore after continuing!", preferredStyle: .alert) var content = UNMutableNotificationContent()
alert.addAction(UIAlertAction(title: NSLocalizedString("Continue", comment: ""), style: .default, handler: { _ in content.title = "Refreshing..."
if installing { content.body = "To finish refreshing, SideStore must force close itself. Please reopen SideStore after it is done refreshing!"
print("Closing SideStore since we are still installing") let notification = UNNotificationRequest(identifier: Bundle.Info.appbundleIdentifier + ".FinishRefreshNotification", content: content, trigger: UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false))
exit(0) UNUserNotificationCenter.current().add(notification)
} else { exit(0)
print("Not closing SideStore since installing finished")
}
}))
let keyWindow = UIApplication.shared.windows.filter { $0.isKeyWindow }.first
if var topController = keyWindow?.rootViewController {
while let presentedViewController = topController.presentedViewController {
topController = presentedViewController
}
topController.present(alert, animated: true)
} else {
print("No key window? Closing SideStore")
exit(0)
}
} else { } else {
print("Installing finished") print("Installing finished")
} }