Meet ActivityKit

This is all about Live Activities

Overview

  • Allow for glanceable ways of keep track of task or event.  Have a defined start and end time.
  • Can use either background or push notifications
  • Dynamic Island can display two live activities at any time.  They will show minimal presentation.
  • You can press to expand to more information 
  • Now supported on StandBy Mode and on iPad 
  • It leverages Widget enhancement to add buttons or toggles.
  • Use ActivityKit framework – it is declarative, very similar to using Home Screen Widgets.  Only available after a discreet user activity.  They are user-moderated like notifications. It must support both Lock Screen and Dynamic Island.

Lifecycle

  • The App goes thru different stages,
    • Request
    • Update
    • Observer activity state
    • End
  • Request app is in foreground, configure initial content and configuration.
    • Setup the update based on information and provide information on state (like when will it be stale).  Reliance is also optional.
    • Define if it is pushType for remote verses local
  • Update
    • Based on key things in the application you can send an update, you can also display alerts if the event is critical.
  • Activity state changes can happen at any time during the Live Activity’s lifecycle (started, finished, dismissed and Failed) are the possible values.  Based on the state changes, you can do cleanup and other activities.
  • End
    • Create a final content and provide that to the item
    • Change the policy 

Building Live Activity UI

  • Need a widget configuration to describe the live activity.
  • Need to define all three Dynamic Island UI
    • Add CompactLeading, compactTrailing, Expanded and minimal views.
  • When more than live activity is running, the system will decide which apps are shown in the dynamic island.
  • Expanded presentation has multiple areas defined by the system. .leading, .trailing, .bottom space.