Compare commits

...

26 Commits

Author SHA1 Message Date
Arthur Ariel Sabintsev df8f8338b3 Updated Package.swift 2020-06-12 10:57:42 -04:00
Arthur Ariel Sabintsev f44a06cd32 Reverted swift-tools-version 2020-06-12 10:54:01 -04:00
Arthur Ariel Sabintsev 68e60f490b Updated manifest 2020-06-12 10:53:03 -04:00
Arthur Ariel Sabintsev 84ece2335f e-updated Package.swift 2020-06-12 10:50:23 -04:00
Arthur Ariel Sabintsev c607fa72f3 Addressed default swift version issue on clone 2020-06-12 10:46:53 -04:00
Arthur Ariel Sabintsev 2f3ed12e00 Addressed default swift version issue on clone 2020-06-12 10:46:41 -04:00
Arthur Ariel Sabintsev dc9b8bbba4 updated podspec 2020-06-12 10:39:46 -04:00
Arthur Ariel Sabintsev 1b95580ad8 Updated plist 2020-06-12 10:29:12 -04:00
Arthur Ariel Sabintsev d9322bdb4f Updated manifest 2020-06-12 10:26:00 -04:00
Arthur Ariel Sabintsev 434e0cd2a0 Updated manifest 2020-06-12 10:22:35 -04:00
Arthur Ariel Sabintsev 2140c28398 Updated manifest 2020-06-12 10:22:29 -04:00
Arthur Ariel Sabintsev b901930ce5 Minor fixes with respect to Xcode 11.5 2020-06-05 08:37:36 -04:00
Arthur Ariel Sabintsev 90fcde1221 Formatting fixes 2020-04-25 15:54:59 -04:00
Arthur Ariel Sabintsev 357afb22ab Removed unnecessary self. references 2020-03-16 21:59:22 -04:00
Arthur Ariel Sabintsev 93e0f66020 Update README.md 2020-03-05 23:30:11 -05:00
Arthur Ariel Sabintsev 7c952267e8 Create FUNDING.yml 2020-02-21 19:22:06 -05:00
Arthur Ariel Sabintsev 7fc6777d3d Bumped podspec to 5.4.0 2020-02-19 23:28:10 -05:00
Giorgio Fiderio ca3559cd93 Delay updaterWindow creation in the PresentationManager (#327) 2020-02-19 23:26:23 -05:00
Arthur Ariel Sabintsev 3c7d06eac0 Revert "Updated README and sample project to support changes found in 5.3.0. Closes #326"
This reverts commit c62c16f1b9.
2020-02-18 09:40:34 -05:00
Arthur Ariel Sabintsev c62c16f1b9 Updated README and sample project to support changes found in 5.3.0. Closes #326 2020-02-15 20:19:53 -05:00
Arthur Ariel Sabintsev 32de6efe8b Updated podspec 2020-02-10 21:02:09 -05:00
Arthur Ariel Sabintsev acfbf2a2d5 Enabled scenes and fixes warning 2020-02-10 21:01:45 -05:00
kisaha00 ad967116cb Fix Create UIWindow (#325) 2020-02-10 21:00:05 -05:00
Arthur Ariel Sabintsev c114526eb8 Cleaning up project hierarchy 2019-12-04 21:30:42 -05:00
Arthur Ariel Sabintsev 70ad233b78 Updated podspec 2019-10-12 09:55:34 -04:00
Arthur Ariel Sabintsev 2b3c9c067d Potential fix for unblocking the UI in iOS 13 (#314)
* Potential fix for unblocking the UI in iOS 13

* Potential fix for layered alert/window issue
2019-10-12 09:52:47 -04:00
9 changed files with 74 additions and 36 deletions
+3
View File
@@ -0,0 +1,3 @@
# These are supported funding model platforms
github: ArtSabintsev
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+10 -4
View File
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
8E1635A91E6A0B9C0060CE27 /* SirenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EE6C74C1E6A0AE100DBE454 /* SirenTests.swift */; };
8EA6AAB323F2424600283B43 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6AAB223F2424600283B43 /* Default-568h@2x.png */; };
8EACA9711F380294003134CA /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8EACA9671F37F2D3003134CA /* LaunchScreen.xib */; };
8EACA9721F380294003134CA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8EACA9691F37F2D3003134CA /* Main.storyboard */; };
8EACA9731F380294003134CA /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8EACA96B1F37F2D3003134CA /* Images.xcassets */; };
@@ -71,6 +72,7 @@
/* Begin PBXFileReference section */
55EC364A1E6BB98A00726F13 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../Siren/Info.plist; sourceTree = "<group>"; };
8E3A6C041D07CB6F00A8B7CF /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8EA6AAB223F2424600283B43 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
8EACA9661F37F2D3003134CA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
8EACA9681F37F2D3003134CA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
8EACA96A1F37F2D3003134CA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
@@ -163,6 +165,7 @@
8EC391781A58B465001C121E = {
isa = PBXGroup;
children = (
8EA6AAB223F2424600283B43 /* Default-568h@2x.png */,
8EACA9651F37F2D3003134CA /* Example */,
8EE6C74A1E6A0AE100DBE454 /* Tests */,
8EF9F854224EACA500B20545 /* Siren */,
@@ -210,8 +213,8 @@
isa = PBXGroup;
children = (
8EF9F861224EACB100B20545 /* APIManager.swift */,
8EF9F862224EACB100B20545 /* RulesManager.swift */,
8EF9F863224EACB100B20545 /* PresentationManager.swift */,
8EF9F862224EACB100B20545 /* RulesManager.swift */,
);
name = Managers;
path = ../../Sources/Managers;
@@ -225,8 +228,8 @@
8EF9F869224EACB100B20545 /* APIModel.swift */,
8EF9F867224EACB100B20545 /* Localization.swift */,
8EF9F868224EACB100B20545 /* Model.swift */,
8EF9F86A224EACB100B20545 /* Rules.swift */,
8EF9F86B224EACB100B20545 /* PerformCheck.swift */,
8EF9F86A224EACB100B20545 /* Rules.swift */,
8EF9F86C224EACB100B20545 /* UpdateResults.swift */,
);
name = Models;
@@ -236,10 +239,10 @@
8EF9F86E224EACB100B20545 /* Extensions */ = {
isa = PBXGroup;
children = (
8EF9F86F224EACB100B20545 /* UIAlertControllerExtension.swift */,
8EF9F870224EACB100B20545 /* BundleExtension.swift */,
8EF9F871224EACB100B20545 /* UserDefaultsExtension.swift */,
8EF9F872224EACB100B20545 /* DateExtension.swift */,
8EF9F86F224EACB100B20545 /* UIAlertControllerExtension.swift */,
8EF9F871224EACB100B20545 /* UserDefaultsExtension.swift */,
);
name = Extensions;
path = ../../Sources/Extensions;
@@ -407,6 +410,7 @@
buildActionMask = 2147483647;
files = (
8EACA9711F380294003134CA /* LaunchScreen.xib in Resources */,
8EA6AAB323F2424600283B43 /* Default-568h@2x.png in Resources */,
8EACA9721F380294003134CA /* Main.storyboard in Resources */,
8EACA9731F380294003134CA /* Images.xcassets in Resources */,
);
@@ -671,6 +675,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.apple.AppStoreConnect;
PRODUCT_NAME = Example;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
@@ -688,6 +693,7 @@
PRODUCT_NAME = Example;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
+6 -5
View File
@@ -21,12 +21,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
/// Siren initializes a listener on `didBecomeActiveNotification` to perform version checks.
// defaultExample()
// defaultExampleUsingCompletionHandler()
defaultExampleUsingCompletionHandler()
// manualExampleWithCompletionHandler()
// minimalCustomizationPresentationExample()
// forceLocalizationCustomizationPresentationExample()
// customMessagingPresentationExample()
annoyingRuleExample()
// annoyingRuleExample()
// hyperCriticalRulesExample()
// updateSpecificRulesExample()
// customAlertRulesExample()
@@ -84,6 +84,7 @@ private extension AppDelegate {
/// Minor customization to Siren's update alert presentation.
func minimalCustomizationPresentationExample() {
let siren = Siren.shared
siren.rulesManager = RulesManager(globalRules: .annoying)
siren.presentationManager = PresentationManager(alertTintColor: .purple,
appName: "Siren Example App Override!")
siren.wail { results in
@@ -99,7 +100,7 @@ private extension AppDelegate {
}
}
/// Forcing the language of the update alert to a specific localization (e.g., Russian is force in this function.
/// Forcing the language of the update alert to a specific localization (e.g., Russian is forced in this function)
func forceLocalizationCustomizationPresentationExample() {
let siren = Siren.shared
siren.presentationManager = PresentationManager(forceLanguageLocalization: .russian)
@@ -221,8 +222,8 @@ private extension AppDelegate {
}
/// An example on how to change the App Store region that your app in which your app is available.
// This should only be used if your app is not available in the US App Store.
// This example function illustrates how this can be done by checking against the Russian App Store.
/// This should only be used if your app is not available in the US App Store.
/// This example function illustrates how this can be done by checking against the Russian App Store.
func appStoreCountryChangeExample() {
let siren = Siren.shared
siren.apiManager = APIManager(countryCode: "RU")
+14
View File
@@ -18,5 +18,19 @@
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
</dict>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
+3 -1
View File
@@ -1,8 +1,10 @@
// swift-tools-version:5.1
// swift-tools-version:5.2
import PackageDescription
let package = Package(
name: "Siren",
swiftLanguageVersions: [.v5],
defaultLocalization: LocalizationTag = "en",
products: [.library(name: "Siren", targets: ["Siren"])],
targets: [.target(name: "Siren", path: "Sources")]
)
+1 -1
View File
@@ -107,7 +107,7 @@ pod 'Siren', :git => 'https://github.com/ArtSabintsev/Siren.git', :branch => 'sw
### Carthage
```swift
github "ArtSabintsev/Siren" // Swift 5.0
github "ArtSabintsev/Siren" // Swift 5.1
github "ArtSabintsev/Siren" "swift5.0" // Swift 5.0
github "ArtSabintsev/Siren" "swift4.2" // Swift 4.2
github "ArtSabintsev/Siren" "swift4.1" // Swift 4.1
+2 -2
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
# Version
s.version = "5.2.2"
s.swift_version = "5.1"
s.version = "5.4.2"
s.swift_version = "5.2"
# Meta
s.name = "Siren"
+35 -23
View File
@@ -9,7 +9,7 @@
import UIKit
/// PresentationManager for Siren
public struct PresentationManager {
public class PresentationManager {
/// Return results or errors obtained from performing a version check with Siren.
typealias CompletionHandler = (AlertAction, String?) -> Void
@@ -38,16 +38,7 @@ public struct PresentationManager {
var alertController: UIAlertController?
/// The `UIWindow` instance that presents the `SirenViewController`.
private var updaterWindow: UIWindow {
let window = UIWindow(frame: UIScreen.main.bounds)
window.windowLevel = UIWindow.Level.alert + 1
let viewController = SirenViewController()
viewController.retainedWindow = window
window.rootViewController = viewController
return window
}
private lazy var updaterWindow = createWindow()
/// `PresentationManager`'s public initializer.
///
@@ -96,9 +87,9 @@ extension PresentationManager {
/// - rules: The rules that are used to define the type of alert that should be presented.
/// - currentAppStoreVersion: The current version of the app in the App Store.
/// - handler: The completion handler that returns the an `AlertAction` depending on the type of action the end-user took.
mutating func presentAlert(withRules rules: Rules,
forCurrentAppStoreVersion currentAppStoreVersion: String,
completion handler: CompletionHandler?) {
func presentAlert(withRules rules: Rules,
forCurrentAppStoreVersion currentAppStoreVersion: String,
completion handler: CompletionHandler?) {
UserDefaults.alertPresentationDate = Date()
// Alert Title
@@ -154,9 +145,7 @@ extension PresentationManager {
func cleanUp() {
alertController?.hide(window: updaterWindow)
alertController?.dismiss(animated: true, completion: nil)
self.updaterWindow.rootViewController = nil
self.updaterWindow.resignKey()
self.updaterWindow.removeFromSuperview()
updaterWindow.resignKey()
}
}
@@ -171,10 +160,10 @@ private extension PresentationManager {
/// - Returns: The `Update` alert action.
func updateAlertAction(completion handler: CompletionHandler?) -> UIAlertAction {
let title: String
if self.updateButtonTitle == AlertConstants.updateButtonTitle {
if updateButtonTitle == AlertConstants.updateButtonTitle {
title = localization.updateButtonTitle()
} else {
title = self.updateButtonTitle
title = updateButtonTitle
}
let action = UIAlertAction(title: title, style: .default) { _ in
@@ -193,10 +182,10 @@ private extension PresentationManager {
/// - Returns: The `Next time` alert action.
func nextTimeAlertAction(completion handler: CompletionHandler?) -> UIAlertAction {
let title: String
if self.nextTimeButtonTitle == AlertConstants.nextTimeButtonTitle {
if nextTimeButtonTitle == AlertConstants.nextTimeButtonTitle {
title = localization.nextTimeButtonTitle()
} else {
title = self.nextTimeButtonTitle
title = nextTimeButtonTitle
}
let action = UIAlertAction(title: title, style: .default) { _ in
@@ -216,10 +205,10 @@ private extension PresentationManager {
/// - Returns: The `Skip this version` alert action.
func skipAlertAction(forCurrentAppStoreVersion currentAppStoreVersion: String, completion handler: CompletionHandler?) -> UIAlertAction {
let title: String
if self.skipButtonTitle == AlertConstants.skipButtonTitle {
if skipButtonTitle == AlertConstants.skipButtonTitle {
title = localization.skipButtonTitle()
} else {
title = self.skipButtonTitle
title = skipButtonTitle
}
let action = UIAlertAction(title: title, style: .default) { _ in
@@ -231,3 +220,26 @@ private extension PresentationManager {
return action
}
}
// MARK: - Helpers
private extension PresentationManager {
private func createWindow() -> UIWindow {
var window = UIWindow()
if #available(iOS 13.0, *) {
guard let windowScene = UIApplication.shared.connectedScenes
.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene else { return UIWindow() }
window = UIWindow(windowScene: windowScene)
} else {
window = UIWindow(frame: UIScreen.main.bounds)
}
window.windowLevel = UIWindow.Level.alert + 1
let viewController = SirenViewController()
viewController.retainedWindow = window
window.rootViewController = viewController
return window
}
}