Created
September 25, 2023 06:30
-
-
Save Kyle-Ye/49d13ea57090d3727fda039fcf4f10b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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