Skip to content

Commit cf9739f

Browse files
committed
1.3.3
1 parent 83948bb commit cf9739f

File tree

4 files changed

+27
-22
lines changed

4 files changed

+27
-22
lines changed

AppStoreManager.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |spec|
22

33
spec.name = "AppStoreManager"
4-
spec.version = "1.3.2"
4+
spec.version = "1.3.3"
55
spec.summary = "A new version checking framework in Swift."
66

77
spec.homepage = "https://knottx.github.io"

AppStoreManager.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
"@executable_path/Frameworks",
382382
"@loader_path/Frameworks",
383383
);
384-
MARKETING_VERSION = 1.3.2;
384+
MARKETING_VERSION = 1.3.3;
385385
PRODUCT_BUNDLE_IDENTIFIER = com.knottx.AppStoreManager;
386386
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
387387
SKIP_INSTALL = YES;
@@ -410,7 +410,7 @@
410410
"@executable_path/Frameworks",
411411
"@loader_path/Frameworks",
412412
);
413-
MARKETING_VERSION = 1.3.2;
413+
MARKETING_VERSION = 1.3.3;
414414
PRODUCT_BUNDLE_IDENTIFIER = com.knottx.AppStoreManager;
415415
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
416416
SKIP_INSTALL = YES;

Sources/AppStoreManager/AppStoreManager.swift

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import 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)

Sources/AppStoreManager/AppStoreManagerModels.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import Foundation
99

1010
struct AppStoreResponse: Decodable {
11-
var resultCount:Int?
12-
var results:[AppStoreResult]
11+
let resultCount: Int?
12+
let results: [AppStoreResult]
1313
}
1414

1515
struct AppStoreResult: Decodable {
16-
var trackId:Int?
17-
var version:String?
18-
var currentVersionReleaseDate:Date?
16+
let trackId: Int?
17+
let version: String?
18+
let currentVersionReleaseDate: Date?
1919

2020
private enum CodingKeys: String, CodingKey {
2121
case trackId
@@ -29,6 +29,8 @@ struct AppStoreResult: Decodable {
2929
self.version = try? container.decodeIfPresent(String.self, forKey: .version)
3030
if let date = try? container.decodeIfPresent(String.self, forKey: .currentVersionReleaseDate) {
3131
self.currentVersionReleaseDate = date.toDate(with: "yyyy-MM-dd'T'HH:mm:ssZ")
32+
} else {
33+
self.currentVersionReleaseDate = nil
3234
}
3335
}
3436

0 commit comments

Comments
 (0)