feat: add support for scheduled Live Activities via startDate#26
Open
ebellumat wants to merge 2 commits intokingstinct:mainfrom
Open
feat: add support for scheduled Live Activities via startDate#26ebellumat wants to merge 2 commits intokingstinct:mainfrom
startDate#26ebellumat wants to merge 2 commits intokingstinct:mainfrom
Conversation
Adds support for Apple's Activity.request(startDate:) API, which allows scheduling a Live Activity to appear at a future date instead of immediately. This uses three reserved attribute keys prefixed with underscore: - _startDate: Unix timestamp (ms) for when the activity should appear - _alertTitle: Title for the notification shown when the activity starts - _alertBody: Body text for the notification When _startDate is present, the activity is scheduled using Activity.request(attributes:content:pushType:style:alertConfiguration:startDate:). When absent, the existing behavior is preserved (backward-compatible). Requires iOS 17.2+ (when Activity.request with startDate was introduced). Use case: Schedule state transitions for Live Activities without relying on background tasks or push notifications. For example, showing a countdown Live Activity immediately and scheduling a second "LIVE NOW" activity to appear automatically at the target time. Reference: https://developer.apple.com/documentation/activitykit/activity/request(attributes:content:pushtype:style:alertconfiguration:startdate:)
|
Refactor Activity.request to handle iOS version differences.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add support for scheduled Live Activities via
startDateAdds support for Apple's
Activity.request(startDate:)API, allowing Live Activities to be scheduled to appear at a future date instead of immediately. Requires iOS 17.2+. Fully backward-compatible.Handles the iOS 26.0 deprecation — uses the new
start:parameter on iOS 26+ and falls back tostartDate:on earlier versions.How it works
Three reserved attribute keys (prefixed with
_to avoid collisions):_startDateDouble_alertTitleString_alertBodyStringWhen
_startDateis present,Activity.request(startDate:)is called with anAlertConfiguration. When absent, existing behavior is preserved.Usage
Use case
Schedule Live Activity state transitions on-device — no server push, no background tasks. Example: start a countdown now, schedule a "LIVE" activity to appear automatically at the target time.
Use case: I was struggling to change a counter to show a simple text after the countdown reaches zero, using two live activities scheduled instead of just one, did the job just right! This way we can transition between states easily.
Working example:
https://github.com/user-attachments/assets/dc4f84ef-32d5-4e85-bfea-3f3d69732dbe