diff --git a/Example/DemoApp/UpdateUtil.swift b/Example/DemoApp/UpdateUtil.swift index 05a9621..eb3d137 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 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 7384b6b..26fc6ce 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 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) + } } }