Skip to content

Commit 6ef98a8

Browse files
- make available for iOS 13
1 parent 795b960 commit 6ef98a8

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import PackageDescription
66
let package = Package(
77
name: "AppBehaviorDispatcher",
88
platforms: [
9-
.iOS(.v14)
9+
.iOS(.v13)
1010
],
1111
products: [
1212
// Products define the executables and libraries a package produces, making them visible to other packages.

Sources/AppBehaviorDispatcher/AppBehaviorDelegate.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,23 @@ open class AppBehaviorDelegate: UIResponder, UIApplicationDelegate, UNUserNotifi
5454
behaviorDispatcher.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
5555
}
5656

57+
@available(iOS 13.2, *)
5758
public func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool {
5859
behaviorDispatcher.application(application, shouldSaveSecureApplicationState: coder)
5960
}
6061

62+
@available(iOS 13.2, *)
6163
public func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool {
6264
behaviorDispatcher.application(application, shouldRestoreSecureApplicationState: coder)
6365
}
6466

67+
public func application(_ application: UIApplication, shouldRestoreApplicationState coder: NSCoder) -> Bool {
68+
behaviorDispatcher.application(application, shouldRestoreApplicationState: coder)
69+
}
70+
71+
public func application(_ application: UIApplication, shouldSaveApplicationState coder: NSCoder) -> Bool {
72+
behaviorDispatcher.application(application, shouldSaveApplicationState: coder)
73+
}
6574

6675
//MARK: - UNUserNotificationCenterDelegate
6776
//

Sources/AppBehaviorDispatcher/AppBehaviorDispatcher+AppStateRestoration.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extension AppBehaviorDispatcher {
2222
return nil
2323
}
2424

25+
@available(iOS 13.2, *)
2526
func application(_ application: UIApplication, shouldSaveSecureApplicationState coder: NSCoder) -> Bool {
2627
var result = false
2728

@@ -34,6 +35,7 @@ extension AppBehaviorDispatcher {
3435
return result
3536
}
3637

38+
@available(iOS 13.2, *)
3739
func application(_ application: UIApplication, shouldRestoreSecureApplicationState coder: NSCoder) -> Bool {
3840
var result = false
3941
for behavior in behaviors {
@@ -44,6 +46,30 @@ extension AppBehaviorDispatcher {
4446

4547
return result
4648
}
49+
50+
func application(_ application: UIApplication, shouldSaveApplicationState coder: NSCoder) -> Bool {
51+
var result = false
52+
53+
for behavior in behaviors {
54+
if behavior.application?(application, shouldSaveApplicationState: coder) ?? false {
55+
result = true
56+
}
57+
}
58+
59+
return result
60+
}
61+
62+
func application(_ application: UIApplication, shouldRestoreApplicationState coder: NSCoder) -> Bool {
63+
var result = false
64+
for behavior in behaviors {
65+
if behavior.application?(application, shouldRestoreApplicationState: coder) ?? false {
66+
result = true
67+
}
68+
}
69+
70+
return result
71+
}
72+
4773

4874
@available(iOS 6.0, *)
4975
func application(_ application: UIApplication, willEncodeRestorableStateWith coder: NSCoder) {

0 commit comments

Comments
 (0)