99
1010import UIKit
1111
12- public enum VersionCheckType : Int {
12+ public enum VersionCheckType : Int {
1313 case immediately = 0
1414 case daily = 1
1515 case weekly = 7
@@ -24,13 +24,13 @@ public class AppStoreManager {
2424
2525 public static let shared = AppStoreManager ( )
2626
27- var title : String = AppStoreManagerConstant . alertTitle
28- var message : String ? = AppStoreManagerConstant . alertMessage
27+ var title : String = AppStoreManagerConstant . alertTitle
28+ var message : String ? = AppStoreManagerConstant . alertMessage
2929
30- var skipButtonTitle : String = AppStoreManagerConstant . skipButtonTitle
31- var updateButtonTitle : String = AppStoreManagerConstant . updateButtonTitle
30+ var skipButtonTitle : String = AppStoreManagerConstant . skipButtonTitle
31+ var updateButtonTitle : String = AppStoreManagerConstant . updateButtonTitle
3232
33- var lastVersionCheckDate : Date ? {
33+ var lastVersionCheckDate : Date ? {
3434 didSet{
3535 UserDefaults . standard. set ( self . lastVersionCheckDate, forKey: AppStoreDefaults . storedVersionCheckDate)
3636 UserDefaults . standard. synchronize ( )
@@ -39,11 +39,11 @@ public class AppStoreManager {
3939
4040 let bundleId = Bundle . main. bundleIdentifier ?? " "
4141
42- var currentInstalledVersion : String ? {
42+ var currentInstalledVersion : String ? {
4343 return Bundle . main. object ( forInfoDictionaryKey: " CFBundleShortVersionString " ) as? String
4444 }
4545
46- var appStoreResult : AppStoreResult ?
46+ var appStoreResult : AppStoreResult ?
4747
4848 init ( ) {
4949 self . lastVersionCheckDate = UserDefaults . standard. object ( forKey: AppStoreDefaults . storedVersionCheckDate) as? Date
@@ -75,7 +75,7 @@ public class AppStoreManager {
7575 task. resume ( )
7676 }
7777
78- public func checkNewVersion( _ type: VersionCheckType , isAvailable: @escaping ( Bool ) -> ( ) ) {
78+ public func checkNewVersion( _ type: VersionCheckType , isAvailable: @escaping ( Bool ) -> ( ) ) {
7979 self . getStoreVersion { [ weak self] ( result) in
8080 if let currentInstalledVersion = self ? . currentInstalledVersion,
8181 let appStoreVersion = result? . version {
@@ -107,7 +107,10 @@ public class AppStoreManager {
107107 }
108108 }
109109
110- public func checkNewVersionAndShowAlert( _ type: VersionCheckType , at vc: UIViewController , canSkip: Bool , preferredStyle: UIAlertController . Style = . alert) {
110+ public func checkNewVersionAndShowAlert( _ type: VersionCheckType ,
111+ at vc: UIViewController ,
112+ canSkip: Bool ,
113+ preferredStyle: UIAlertController . Style = . alert) {
111114 self . getStoreVersion { [ weak self] ( result) in
112115 if let currentInstalledVersion = self ? . currentInstalledVersion,
113116 let appStoreVersion = result? . version {
@@ -126,17 +129,17 @@ public class AppStoreManager {
126129
127130 //MARK: - Alert
128131
129- public func configureAlert( title: String ? , message: String ? ) {
132+ public func configureAlert( title: String ? , message: String ? ) {
130133 self . title = title ?? AppStoreManagerConstant . alertTitle
131134 self . message = message
132135 }
133136
134- public func configureAlert( updateButtonTitle: String ? , skipButtonTitle: String ? ) {
137+ public func configureAlert( updateButtonTitle: String ? , skipButtonTitle: String ? ) {
135138 self . updateButtonTitle = updateButtonTitle ?? AppStoreManagerConstant . updateButtonTitle
136139 self . skipButtonTitle = skipButtonTitle ?? AppStoreManagerConstant . skipButtonTitle
137140 }
138141
139- public func showAlertUpdate( at vc: UIViewController , canSkip: Bool , preferredStyle: UIAlertController . Style = . alert) {
142+ public func showAlertUpdate( at vc: UIViewController , canSkip: Bool , preferredStyle: UIAlertController . Style = . alert) {
140143 DispatchQueue . main. async { [ weak self] in
141144 let alertVc = UIAlertController ( title: self ? . title, message: self ? . message, preferredStyle: preferredStyle)
142145 let skip = UIAlertAction ( title: AppStoreManagerConstant . skipButtonTitle, style: . cancel) { ( _) in
@@ -167,7 +170,7 @@ public class AppStoreManager {
167170 }
168171 }
169172
170- func openAppStore( id appStoreId: Int ) {
173+ func openAppStore( id appStoreId: Int ) {
171174 if let url = URL ( string: " https://itunes.apple.com/app/id \( appStoreId) " ) ,
172175 UIApplication . shared. canOpenURL ( url) {
173176 UIApplication . shared. open ( url, options: [ : ] , completionHandler: nil )
0 commit comments