From 7d1f832ae715498f06e538db4b2a284b747ccbea Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Fri, 21 Sep 2018 17:07:24 -0400 Subject: [PATCH 01/10] Converted SirenAlertMessaging strings to type of NSAttributedString --- Sources/Siren.swift | 20 ++++++++++++-------- Sources/SirenAlertMessaging.swift | 30 +++++++++++++++--------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Sources/Siren.swift b/Sources/Siren.swift index 8aa08156..b56b8a71 100644 --- a/Sources/Siren.swift +++ b/Sources/Siren.swift @@ -290,7 +290,8 @@ private extension Siren { func showAlert() { storeVersionCheckDate() - let updateAvailableMessage = Bundle.localizedString(forKey: alertMessaging.updateTitle, forceLanguageLocalization: forceLanguageLocalization) + let updateAvailableMessage = Bundle.localizedString(forKey: alertMessaging.updateTitle.string, + forceLanguageLocalization: forceLanguageLocalization) let newVersionMessage = localizedNewVersionMessage() @@ -411,13 +412,13 @@ private extension Siren { private extension Siren { func localizedUpdateTitle() -> String { - let updateTitleToLocalize = alertMessaging.updateTitle - return Bundle.localizedString(forKey: updateTitleToLocalize, forceLanguageLocalization: forceLanguageLocalization) + return Bundle.localizedString(forKey: alertMessaging.updateTitle.string, + forceLanguageLocalization: forceLanguageLocalization) } func localizedNewVersionMessage() -> String { - let newVersionMessageToLocalize = alertMessaging.updateMessage - let newVersionMessage = Bundle.localizedString(forKey: newVersionMessageToLocalize, forceLanguageLocalization: forceLanguageLocalization) + let newVersionMessage = Bundle.localizedString(forKey: alertMessaging.updateMessage.string, + forceLanguageLocalization: forceLanguageLocalization) guard let currentAppStoreVersion = currentAppStoreVersion else { return String(format: newVersionMessage, appName, "Unknown") @@ -427,15 +428,18 @@ private extension Siren { } func localizedUpdateButtonTitle() -> String { - return Bundle.localizedString(forKey: alertMessaging.updateButtonMessage, forceLanguageLocalization: forceLanguageLocalization) + return Bundle.localizedString(forKey: alertMessaging.updateButtonMessage.string, + forceLanguageLocalization: forceLanguageLocalization) } func localizedNextTimeButtonTitle() -> String { - return Bundle.localizedString(forKey: alertMessaging.nextTimeButtonMessage, forceLanguageLocalization: forceLanguageLocalization) + return Bundle.localizedString(forKey: alertMessaging.nextTimeButtonMessage.string, + forceLanguageLocalization: forceLanguageLocalization) } func localizedSkipButtonTitle() -> String { - return Bundle.localizedString(forKey: alertMessaging.skipVersionButtonMessage, forceLanguageLocalization: forceLanguageLocalization) + return Bundle.localizedString(forKey: alertMessaging.skipVersionButtonMessage.string, + forceLanguageLocalization: forceLanguageLocalization) } } diff --git a/Sources/SirenAlertMessaging.swift b/Sources/SirenAlertMessaging.swift index 2c253558..12db03ee 100644 --- a/Sources/SirenAlertMessaging.swift +++ b/Sources/SirenAlertMessaging.swift @@ -21,26 +21,26 @@ public struct SirenAlertMessaging { public struct Constants { /// The button text that conveys the message that the user should be prompted to update next time the app launches. - public static let nextTime = "Next time" + public static let nextTime = NSAttributedString(string: "Next time") /// The text that conveys the message that the the user wants to skip this verison update. - public static let skipVersion = "Skip this version" + public static let skipVersion = NSAttributedString(string: "Skip this version") /// The text that conveys the message that there is an app update available - public static let updateMessage = "A new version of %@ is available. Please update to version %@ now." + public static let updateMessage = NSAttributedString(string: "A new version of %@ is available. Please update to version %@ now.") /// The alert title which defaults to *Update Available*. - public static let updateTitle = "Update Available" + public static let updateTitle = NSAttributedString(string: "Update Available") /// The button text that conveys the message that the user would like to update the app right away. - public static let updateNow = "Update" + public static let updateNow = NSAttributedString(string: "Update") } - let nextTimeButtonMessage: String - let skipVersionButtonMessage: String - let updateButtonMessage: String - let updateMessage: String - let updateTitle: String + let nextTimeButtonMessage: NSAttributedString + let skipVersionButtonMessage: NSAttributedString + let updateButtonMessage: NSAttributedString + let updateMessage: NSAttributedString + let updateTitle: NSAttributedString /// The public initializer /// @@ -50,11 +50,11 @@ public struct SirenAlertMessaging { /// - updateButtonMessage: The `title` field of the Update Button `UIAlertAction`. /// - nextTimeButtonMessage: The `title` field of the Next Time Button `UIAlertAction`. /// - skipVersionButtonMessage: The `title` field of the Skip Button `UIAlertAction`. - public init(updateTitle title: String = Constants.updateTitle, - updateMessage message: String = Constants.updateMessage, - updateButtonMessage: String = Constants.updateNow, - nextTimeButtonMessage: String = Constants.nextTime, - skipVersionButtonMessage: String = Constants.skipVersion) { + public init(updateTitle title: NSAttributedString = Constants.updateTitle, + updateMessage message: NSAttributedString = Constants.updateMessage, + updateButtonMessage: NSAttributedString = Constants.updateNow, + nextTimeButtonMessage: NSAttributedString = Constants.nextTime, + skipVersionButtonMessage: NSAttributedString = Constants.skipVersion) { self.updateTitle = title self.nextTimeButtonMessage = nextTimeButtonMessage self.updateButtonMessage = updateButtonMessage From 0a0eb45edabedc39585acbf01e4f84bcee3249f4 Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Fri, 21 Sep 2018 17:08:59 -0400 Subject: [PATCH 02/10] Updated documentation --- Sources/SirenAlertMessaging.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SirenAlertMessaging.swift b/Sources/SirenAlertMessaging.swift index 12db03ee..0ed04817 100644 --- a/Sources/SirenAlertMessaging.swift +++ b/Sources/SirenAlertMessaging.swift @@ -14,7 +14,7 @@ import Foundation /// /// - Warning: Overriding any of these keys will result in the loss of the built-in internationalization that Siren provides. /// -/// As SirenAlertMessaging is a Struct, one _or_ more keys can be modified. Overriding only one string will result in the other keys retaining their default (and internationalizable) values. +/// As `SirenAlertMessaging` is a Struct, one _or_ more keys can be modified. Overriding only one string will result in the other keys retaining their default (and internationalizable) values. public struct SirenAlertMessaging { /// The default constants used for the alert messaging. From 1fd5c7d07f9058c41f2e7572f53dee3dd29d90ce Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Fri, 21 Sep 2018 17:09:50 -0400 Subject: [PATCH 03/10] Removed whitespace --- Sources/SirenAlertMessaging.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/SirenAlertMessaging.swift b/Sources/SirenAlertMessaging.swift index 0ed04817..ca27dbc8 100644 --- a/Sources/SirenAlertMessaging.swift +++ b/Sources/SirenAlertMessaging.swift @@ -61,5 +61,4 @@ public struct SirenAlertMessaging { self.updateMessage = message self.skipVersionButtonMessage = skipVersionButtonMessage } - } From 3a8fe9770d26b050da2e9ddfc8b3332959644267 Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Fri, 21 Sep 2018 17:14:37 -0400 Subject: [PATCH 04/10] Removed more whitespace --- Sources/Siren.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/Sources/Siren.swift b/Sources/Siren.swift index b56b8a71..9f69a396 100644 --- a/Sources/Siren.swift +++ b/Sources/Siren.swift @@ -161,13 +161,11 @@ public final class Siren: NSObject { } } } - } // MARK: - Helpers (Networking) private extension Siren { - func performVersionCheck() { do { let url = try iTunesURLFromString() From 7cde1664d1cd2bc7bf8477235ec6dfcbb3c75723 Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Sat, 22 Sep 2018 15:14:19 -0400 Subject: [PATCH 05/10] Updated sample code and README --- Example/Example/AppDelegate.swift | 12 +++++------ README.md | 33 ++++++++++++++++--------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift index 2f174870..c3c8d9cc 100755 --- a/Example/Example/AppDelegate.swift +++ b/Example/Example/AppDelegate.swift @@ -35,12 +35,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // siren.appName = "Test App Name" // Optional - Change the various UIAlertController and UIAlertAction messaging. One or more values can be changes. If only a subset of values are changed, the defaults with which Siren comes with will be used. -// siren.alertMessaging = SirenAlertMessaging(updateTitle: "New Fancy Title", -// updateMessage: "New message goes here!", -// updateButtonMessage: "Update Now, Plz!?", -// nextTimeButtonMessage: "OK, next time it is!", -// skipVersionButtonMessage: "Please don't push skip, please don't!") - + siren.alertMessaging = SirenAlertMessaging(updateTitle: NSAttributedString(string: "New Fancy Title"), + updateMessage: NSAttributedString(string: "New message goes here!"), + updateButtonMessage: NSAttributedString(string: "Update Now, Plz!?"), + nextTimeButtonMessage: NSAttributedString(string: "OK, next time it is!"), + skipVersionButtonMessage: NSAttributedString(string: "Please don't push skip, please don't!")) + // Optional - Defaults to .Option // siren.alertType = .option // or .force, .skip, .none diff --git a/README.md b/README.md index d1eb388b..5ad07016 100755 --- a/README.md +++ b/README.md @@ -104,27 +104,28 @@ For a full list of optional settings/preferences, please refer to https://github func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { /* Siren code should go below window?.makeKeyAndVisible() */ - // Siren is a singleton - let siren = Siren.shared + // Siren is a singleton + let siren = Siren.shared - // Optional: Defaults to .option - siren.alertType = <#Siren.AlertType_Enum_Value#> + // Optional: Defaults to .option + siren.alertType = <#Siren.AlertType_Enum_Value#> - // Optional: Change the various UIAlertController and UIAlertAction messaging. One or more values can be changes. If only a subset of values are changed, the defaults with which Siren comes with will be used. - siren.alertMessaging = SirenAlertMessaging(updateTitle: "New Fancy Title", - updateMessage: "New message goes here!", - updateButtonMessage: "Update Now, Plz!?", - nextTimeButtonMessage: "OK, next time it is!", - skipVersionButtonMessage: "Please don't push skip, please don't!") + // Optional: Change the various UIAlertController and UIAlertAction messaging. One or more values can be changes. If only a subset of values are changed, the defaults with which Siren comes with will be used. + siren.alertMessaging = SirenAlertMessaging(updateTitle: NSAttributedString(string: "New Fancy Title"), + updateMessage: NSAttributedString(string: "New message goes here!"), + updateButtonMessage: NSAttributedString(string: "Update Now, Plz!?"), + nextTimeButtonMessage: NSAttributedString(string: "OK, next time it is!"), + skipVersionButtonMessage: NSAttributedString(string: "Please don't push skip, please don't!")) - // Optional: Set this variable if you would only like to show an alert if your app has been available on the store for a few days. - // This default value is set to 1 to avoid this issue: https://github.com/ArtSabintsev/Siren#words-of-caution - // To show the update immediately after Apple has updated their JSON, set this value to 0. Not recommended due to aforementioned reason in https://github.com/ArtSabintsev/Siren#words-of-caution. - siren.showAlertAfterCurrentVersionHasBeenReleasedForDays = 3 - // Replace .immediately with .daily or .weekly to specify a maximum daily or weekly frequency for version checks. + // Optional: Set this variable if you would only like to show an alert if your app has been available on the store for a few days. + // This default value is set to 1 to avoid this issue: https://github.com/ArtSabintsev/Siren#words-of-caution + // To show the update immediately after Apple has updated their JSON, set this value to 0. Not recommended due to aforementioned reason in https://github.com/ArtSabintsev/Siren#words-of-caution. + siren.showAlertAfterCurrentVersionHasBeenReleasedForDays = 3 + + // Replace .immediately with .daily or .weekly to specify a maximum daily or weekly frequency for version checks. // DO NOT CALL THIS METHOD IN didFinishLaunchingWithOptions IF YOU ALSO PLAN TO CALL IT IN applicationDidBecomeActive. - siren.checkVersion(checkType: .immediately) + siren.checkVersion(checkType: .immediately) return true } From cf08e79597e5ba7da28a467ef78f8455fa24f907 Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Sat, 22 Sep 2018 15:14:46 -0400 Subject: [PATCH 06/10] Updated sample code and README --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5ad07016..b865927e 100755 --- a/README.md +++ b/README.md @@ -104,28 +104,28 @@ For a full list of optional settings/preferences, please refer to https://github func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { /* Siren code should go below window?.makeKeyAndVisible() */ - // Siren is a singleton - let siren = Siren.shared + // Siren is a singleton + let siren = Siren.shared - // Optional: Defaults to .option - siren.alertType = <#Siren.AlertType_Enum_Value#> + // Optional: Defaults to .option + siren.alertType = <#Siren.AlertType_Enum_Value#> - // Optional: Change the various UIAlertController and UIAlertAction messaging. One or more values can be changes. If only a subset of values are changed, the defaults with which Siren comes with will be used. - siren.alertMessaging = SirenAlertMessaging(updateTitle: NSAttributedString(string: "New Fancy Title"), - updateMessage: NSAttributedString(string: "New message goes here!"), - updateButtonMessage: NSAttributedString(string: "Update Now, Plz!?"), - nextTimeButtonMessage: NSAttributedString(string: "OK, next time it is!"), - skipVersionButtonMessage: NSAttributedString(string: "Please don't push skip, please don't!")) + // Optional: Change the various UIAlertController and UIAlertAction messaging. One or more values can be changes. If only a subset of values are changed, the defaults with which Siren comes with will be used. + siren.alertMessaging = SirenAlertMessaging(updateTitle: NSAttributedString(string: "New Fancy Title"), + updateMessage: NSAttributedString(string: "New message goes here!"), + updateButtonMessage: NSAttributedString(string: "Update Now, Plz!?"), + nextTimeButtonMessage: NSAttributedString(string: "OK, next time it is!"), + skipVersionButtonMessage: NSAttributedString(string: "Please don't push skip, please don't!")) - // Optional: Set this variable if you would only like to show an alert if your app has been available on the store for a few days. - // This default value is set to 1 to avoid this issue: https://github.com/ArtSabintsev/Siren#words-of-caution - // To show the update immediately after Apple has updated their JSON, set this value to 0. Not recommended due to aforementioned reason in https://github.com/ArtSabintsev/Siren#words-of-caution. - siren.showAlertAfterCurrentVersionHasBeenReleasedForDays = 3 + // Optional: Set this variable if you would only like to show an alert if your app has been available on the store for a few days. + // This default value is set to 1 to avoid this issue: https://github.com/ArtSabintsev/Siren#words-of-caution + // To show the update immediately after Apple has updated their JSON, set this value to 0. Not recommended due to aforementioned reason in https://github.com/ArtSabintsev/Siren#words-of-caution. + siren.showAlertAfterCurrentVersionHasBeenReleasedForDays = 3 - // Replace .immediately with .daily or .weekly to specify a maximum daily or weekly frequency for version checks. - // DO NOT CALL THIS METHOD IN didFinishLaunchingWithOptions IF YOU ALSO PLAN TO CALL IT IN applicationDidBecomeActive. - siren.checkVersion(checkType: .immediately) + // Replace .immediately with .daily or .weekly to specify a maximum daily or weekly frequency for version checks. + // DO NOT CALL THIS METHOD IN didFinishLaunchingWithOptions IF YOU ALSO PLAN TO CALL IT IN applicationDidBecomeActive. + siren.checkVersion(checkType: .immediately) return true } From d192ef4f32584ec91f79e62eac0ac675aad02ffc Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Sat, 22 Sep 2018 15:15:07 -0400 Subject: [PATCH 07/10] Updated sample code and README --- Example/Example/AppDelegate.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift index c3c8d9cc..fb24f4fa 100755 --- a/Example/Example/AppDelegate.swift +++ b/Example/Example/AppDelegate.swift @@ -35,11 +35,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // siren.appName = "Test App Name" // Optional - Change the various UIAlertController and UIAlertAction messaging. One or more values can be changes. If only a subset of values are changed, the defaults with which Siren comes with will be used. - siren.alertMessaging = SirenAlertMessaging(updateTitle: NSAttributedString(string: "New Fancy Title"), - updateMessage: NSAttributedString(string: "New message goes here!"), - updateButtonMessage: NSAttributedString(string: "Update Now, Plz!?"), - nextTimeButtonMessage: NSAttributedString(string: "OK, next time it is!"), - skipVersionButtonMessage: NSAttributedString(string: "Please don't push skip, please don't!")) +// siren.alertMessaging = SirenAlertMessaging(updateTitle: NSAttributedString(string: "New Fancy Title"), +// updateMessage: NSAttributedString(string: "New message goes here!"), +// updateButtonMessage: NSAttributedString(string: "Update Now, Plz!?"), +// nextTimeButtonMessage: NSAttributedString(string: "OK, next time it is!"), +// skipVersionButtonMessage: NSAttributedString(string: "Please don't push skip, please don't!")) // Optional - Defaults to .Option // siren.alertType = .option // or .force, .skip, .none From db9987102fcab4d920b143672dc9769cac9d540d Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Sat, 22 Sep 2018 15:17:27 -0400 Subject: [PATCH 08/10] Added some docs --- README.md | 6 +++--- Sources/SirenDelegate.swift | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b865927e..6670a4d0 100755 --- a/README.md +++ b/README.md @@ -168,9 +168,9 @@ func application(application: UIApplication, didFinishLaunchingWithOptions launc extension AppDelegate: SirenDelegate { // Returns a localized message to this delegate method upon performing a successful version check - func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType) { - print("\(message)") - } + func sirenDidDetectNewVersionWithoutAlert(message: String, updateType: UpdateType) { + print("\(message)") + } } ``` diff --git a/Sources/SirenDelegate.swift b/Sources/SirenDelegate.swift index 43c84d2c..87e56977 100644 --- a/Sources/SirenDelegate.swift +++ b/Sources/SirenDelegate.swift @@ -42,6 +42,8 @@ public protocol SirenDelegate: NSObjectProtocol { func sirenDidFailVersionCheck(error: Error) /// User presented with an update dialog. + /// + /// - Parameter alertType: The type of alert that was presented. func sirenDidShowUpdateDialog(alertType: Siren.AlertType) /// Siren performed a version check and the latest version was already installed. From 3b4f3eb18ea6715076948db7bd3fd00836f7ff94 Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Sat, 22 Sep 2018 15:39:10 -0400 Subject: [PATCH 09/10] Updated Gems --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2b259bd3..5490f76c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,7 +79,7 @@ GEM rubygems-bundler (1.4.5) bundler-unload (>= 1.0.2) executable-hooks (>= 1.5.0) - sass (3.5.7) + sass (3.6.0) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) From 5dd4965b5bea937de5e01481cbec073dc3251c4b Mon Sep 17 00:00:00 2001 From: Arthur Ariel Sabintsev Date: Sat, 22 Sep 2018 15:40:50 -0400 Subject: [PATCH 10/10] Updated podspec --- Siren.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Siren.podspec b/Siren.podspec index df85cf09..5add3dee 100755 --- a/Siren.podspec +++ b/Siren.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| # Version - s.version = "3.5.1" + s.version = "3.6.0" s.swift_version = '4.2' # Meta