Skip to content

Instantly share code, notes, and snippets.

@Kyle-Ye
Created September 25, 2023 06:30
Show Gist options
  • Save Kyle-Ye/49d13ea57090d3727fda039fcf4f10b9 to your computer and use it in GitHub Desktop.
Save Kyle-Ye/49d13ea57090d3727fda039fcf4f10b9 to your computer and use it in GitHub Desktop.
// The behavior before iOS 17/Xcode 15:
// Dynamic Island Device: Alert if app is in background
// non-Dynamic Island Device: Alert if app is in background
//
// The behavior after iOS 17/Xcode 15:
// Dynamic Island Device: Alert if or after app is in background
// non-Dynamic Island Device: Alert immediately
//
// "Alert" means a pop-up live activity card with white backgroun
// To workaround the buggy UI behavior for non-Dynamic Island Device on iOS 17
// We add backgroundState check here
let alertConfiguration: AlertConfiguration?
if UIApplication.shared.applicationState == .background {
alertConfiguration = AlertConfiguration(title: "✅", body: "\(activity.attributes.title) complete 🎉", sound: .default)
} else {
alertConfiguration = nil
}
await activity.update(using: status, alertConfiguration: alertConfiguration)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment