Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df8f8338b3 | |||
| f44a06cd32 | |||
| 68e60f490b | |||
| 84ece2335f | |||
| c607fa72f3 | |||
| 2f3ed12e00 | |||
| dc9b8bbba4 | |||
| 1b95580ad8 | |||
| d9322bdb4f | |||
| 434e0cd2a0 | |||
| 2140c28398 | |||
| b901930ce5 | |||
| 90fcde1221 | |||
| 357afb22ab | |||
| 93e0f66020 | |||
| 7c952267e8 | |||
| 7fc6777d3d | |||
| ca3559cd93 | |||
| 3c7d06eac0 | |||
| c62c16f1b9 | |||
| 32de6efe8b | |||
| acfbf2a2d5 | |||
| ad967116cb | |||
| c114526eb8 | |||
| 70ad233b78 | |||
| 2b3c9c067d |
@@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: ArtSabintsev
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
@@ -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")]
|
||||
)
|
||||
|
||||
@@ -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
@@ -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"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user