diff --git a/Signal/src/util/AppUpdateNag.swift b/Signal/src/util/AppUpdateNag.swift index 416bacf8f..63152d418 100644 --- a/Signal/src/util/AppUpdateNag.swift +++ b/Signal/src/util/AppUpdateNag.swift @@ -39,7 +39,7 @@ class AppUpdateNag: NSObject { self.versionService.fetchLatestVersion(lookupURL: lookupURL) }.then { appStoreRecord -> Void in guard appStoreRecord.version.compare(currentVersion, options: .numeric) == ComparisonResult.orderedDescending else { - Logger.debug("\(self.logTag) same old version: \(appStoreRecord)") + Logger.debug("\(self.logTag) remote version: \(appStoreRecord) is not newer than currentVersion: \(currentVersion)") return } @@ -128,20 +128,25 @@ class AppUpdateNag: NSObject { func presentUpgradeNag(appStoreRecord: AppStoreRecord) { let title = NSLocalizedString("APP_UPDATE_NAG_ALERT_TITLE", comment: "Title for the 'new app version available' alert.") - let messageFormat = NSLocalizedString("APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT", comment: "Message format for the 'new app version available' alert. Embeds: {{The latest app version number}}") - let message = String(format: messageFormat, appStoreRecord.version) - let buttonTitle = NSLocalizedString("APP_UPDATE_NAG_ALERT_UPDATE_BUTTON", comment: "Label for the 'update' button in the 'new app version available' alert.") + let bodyFormat = NSLocalizedString("APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT", comment: "Message format for the 'new app version available' alert. Embeds: {{The latest app version number}}") + let bodyText = String(format: bodyFormat, appStoreRecord.version) + let updateButtonText = NSLocalizedString("APP_UPDATE_NAG_ALERT_UPDATE_BUTTON", comment: "Label for the 'update' button in the 'new app version available' alert.") + let dismissButtonText = NSLocalizedString("APP_UPDATE_NAG_ALERT_DISMISS_BUTTON", comment: "Label for the 'dismiss' button in the 'new app version available' alert.") - OWSAlerts.showAlert(title: title, - message: message, - buttonTitle: buttonTitle, - buttonAction: { [weak self] _ in - guard let strongSelf = self else { - return - } + let alert = UIAlertController(title: title, message: bodyText, preferredStyle: .alert) - strongSelf.showAppStore(appStoreURL: appStoreRecord.appStoreURL) - }) + let updateAction = UIAlertAction(title: updateButtonText, style: .default) { [weak self] _ in + guard let strongSelf = self else { + return + } + + strongSelf.showAppStore(appStoreURL: appStoreRecord.appStoreURL) + } + + alert.addAction(updateAction) + alert.addAction(UIAlertAction(title: dismissButtonText, style: .cancel, handler: nil)) + + OWSAlerts.showAlert(alert) } func showAppStore(appStoreURL: URL) { diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index a54ebc498..a58f1aa27 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -77,7 +77,10 @@ /* Text prompting user to edit their profile name. */ "APP_SETTINGS_EDIT_PROFILE_NAME_PROMPT" = "Enter your name"; -/* Message format for the 'new app version available' alert. Embeds: {{The latest app version number.}}. */ +/* Label for the 'dismiss' button in the 'new app version available' alert. */ +"APP_UPDATE_NAG_ALERT_DISMISS_BUTTON" = "Not Now"; + +/* Message format for the 'new app version available' alert. Embeds: {{The latest app version number}} */ "APP_UPDATE_NAG_ALERT_MESSAGE_FORMAT" = "Version %@ is now available in the App Store."; /* Title for the 'new app version available' alert. */ diff --git a/SignalMessaging/views/OWSAlerts.swift b/SignalMessaging/views/OWSAlerts.swift index 2c3fdfcee..83649cad8 100644 --- a/SignalMessaging/views/OWSAlerts.swift +++ b/SignalMessaging/views/OWSAlerts.swift @@ -22,6 +22,15 @@ import Foundation CurrentAppContext().frontmostViewController()?.present(alertController, animated: true, completion: nil) } + @objc + public class func showAlert(_ alert: UIAlertController) { + guard let frontmostViewController = CurrentAppContext().frontmostViewController() else { + owsFail("\(self.logTag) in \(#function) frontmostViewController was unexpectedly nil") + return + } + frontmostViewController.present(alert, animated: true, completion: nil) + } + @objc public class func showAlert(title: String) { self.showAlert(title: title, message: nil, buttonTitle: nil)