Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Example/DemoApp/UpdateUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,14 @@ struct UpdateUtil {
}
DispatchQueue.main.async {
UIApplication.shared.open(url) { _ in
exit(0)
// Post notification event before closing the app

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it maybe make sense to mention here that the Cocoa SDK needs this for a working watchdog termination logic. We have a soft contract here, that is very easy to break if somebody removes the delay below or posting the notification.

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)
}
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions Sources/ETDistribution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down