From 3dfbeaf8a4c0df8967aea5a64659f64e43110eaf Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Tue, 5 Aug 2025 18:03:25 -0300 Subject: [PATCH 1/2] Post UIApplication.willTerminateNotification before exiting the app --- Example/DemoApp/UpdateUtil.swift | 9 ++++++++- Sources/ETDistribution.swift | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Example/DemoApp/UpdateUtil.swift b/Example/DemoApp/UpdateUtil.swift index 05a9621..62991dd 100644 --- a/Example/DemoApp/UpdateUtil.swift +++ b/Example/DemoApp/UpdateUtil.swift @@ -83,7 +83,14 @@ struct UpdateUtil { } DispatchQueue.main.async { UIApplication.shared.open(url) { _ in - exit(0) + // Post notification event before closing the app + NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) + + // Close the app after a slight delay so it has time to execute code fot the notification + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + // We need to exit since iOS doesn't start the install until the app exits + exit(0) + } } } } diff --git a/Sources/ETDistribution.swift b/Sources/ETDistribution.swift index 7384b6b..2970cb5 100644 --- a/Sources/ETDistribution.swift +++ b/Sources/ETDistribution.swift @@ -276,8 +276,14 @@ public final class ETDistribution: NSObject { return } UIApplication.shared.open(url) { _ in - // We need to exit since iOS doesn't start the install until the app exits - exit(0) + // Post notification event before closing the app + NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) + + // Close the app after a slight delay so it has time to execute code fot the notification + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { + // We need to exit since iOS doesn't start the install until the app exits + exit(0) + } } } From 40c5153244c5e17004373695635a7c090d7e6d4e Mon Sep 17 00:00:00 2001 From: Itay Brenner Date: Wed, 6 Aug 2025 10:00:38 -0300 Subject: [PATCH 2/2] Fix typo --- Example/DemoApp/UpdateUtil.swift | 2 +- Sources/ETDistribution.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Example/DemoApp/UpdateUtil.swift b/Example/DemoApp/UpdateUtil.swift index 62991dd..eb3d137 100644 --- a/Example/DemoApp/UpdateUtil.swift +++ b/Example/DemoApp/UpdateUtil.swift @@ -86,7 +86,7 @@ struct UpdateUtil { // Post notification event before closing the app NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) - // Close the app after a slight delay so it has time to execute code fot the notification + // Close the app after a slight delay so it has time to execute code for the notification DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { // We need to exit since iOS doesn't start the install until the app exits exit(0) diff --git a/Sources/ETDistribution.swift b/Sources/ETDistribution.swift index 2970cb5..26fc6ce 100644 --- a/Sources/ETDistribution.swift +++ b/Sources/ETDistribution.swift @@ -279,7 +279,7 @@ public final class ETDistribution: NSObject { // Post notification event before closing the app NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil) - // Close the app after a slight delay so it has time to execute code fot the notification + // Close the app after a slight delay so it has time to execute code for the notification DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { // We need to exit since iOS doesn't start the install until the app exits exit(0)