View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • AI & Machine Learning
    • App Intents
    • Apple Intelligence
    • Games
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Review Help
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Videos

Abrir menú Cerrar menú
  • Colecciones
  • Todos los videos
  • Información

Más videos

  • Información
  • Código
  • Lleva las actividades en vivo a la Mac

    Descubre cómo controlar las actividades en vivo desde tu app de Mac. Explora cómo aparecen las actividades en vivo en la barra de menús y en la Dynamic Island. Aprende a definir tu modelo de datos, crear vistas compactas y ampliadas con SwiftUI e impulsar actualizaciones interactivas mediante App Intents.

    Capítulos

    • 0:00 - Introduction
    • 0:54 - Live Activities on Mac
    • 1:43 - Define the data model
    • 2:51 - Build the views
    • 4:40 - Start and update an activity
    • 5:38 - Add actions
    • 6:25 - End an activity
    • 6:44 - Next steps

    Recursos

    • Starting and updating Live Activities with ActivityKit push notifications
    • Displaying live data with Live Activities
      • Video HD
      • Video SD

    Videos relacionados

    WWDC23

    • Update Live Activities with push notifications
  • Buscar este video…
    • 2:36 - Define the Live Activity data model

      import ActivityKit
      
      struct CurtainActivityAttributes: ActivityAttributes {
          let scenesPerAct: [Int]
          let showTitle: String
      
          struct ContentState: Codable, Hashable {
              var isPlaying: Bool
              var curtainOpen: Bool
              var actIndex: Int
              var sceneIndexInAct: Int
          }
      }
    • 3:20 - Configure compact, minimal, and expanded views

      import SwiftUI
      import WidgetKit
      
      struct CurtainActivityWidget: Widget {
          var body: some WidgetConfiguration {
              ActivityConfiguration(
                  for: CurtainActivityAttributes.self
              ) { context in
                  CurtainActivityMenuBarExpandedContent(
                      state: context.state,
                      showTitle: context.attributes.showTitle)
              } dynamicIsland: { context in
                  DynamicIsland {
                      DynamicIslandExpandedRegion(.leading) {
                          CurtainLabel(state: context.state)
                      }
                      DynamicIslandExpandedRegion(.trailing) {
                          ActLabel(state: context.state)
                      }
                      DynamicIslandExpandedRegion(.center) {
                          SceneLabel(state: context.state)
                      }
                      DynamicIslandExpandedRegion(.bottom) {
                          ExpandedBottom(state: context.state)
                      }
                  } compactLeading: {
                      StatusGlyph(state: context.state)
                  } compactTrailing: {
                      CompactTrailing(state: context.state)
                  } minimal: {
                      StatusGlyph(state: context.state)
                  }
              }
          }
      }
    • 5:23 - Update a running Live Activity

      contentState.curtainOpen = false
      let content = ActivityContent(
          state: self.currentContentState, staleDate: nil
      )
      await activity.update(
          content, alertConfiguration: alertConfiguration
      )
    • 6:02 - Define an App Intent action

      struct SetPlacesReadyIntent: AppIntent {
          // ...
          func perform() async throws -> some IntentResult {
              // ...
              var state = activity.content.state
              state.placesReady = self.ready
              let content = ActivityContent(state: state, staleDate: nil)
              await activity.update(
                  content,
                  alertConfiguration: .announcement(self.ready ? "Ready" : "Not Ready")
              )
              return .result()
          }
      }
    • 6:16 - Trigger the intent from buttons

      private struct PlacesReadyButtons: View {
          var body: some View {
              HStack {
                  Button(intent: SetPlacesReadyIntent(ready: false)) {
                      Text("Not Ready")
                  }
                  .tint(.red)
                  Button(intent: SetPlacesReadyIntent(ready: true)) {
                      Text("Ready")
                  }
                  .tint(.green)
              }
          }
      }
    • 6:32 - End a Live Activity

      // End a Live Activity
      await activity.end(nil, dismissalPolicy: .immediate)

Developer Footer

  • Videos
  • Tech Talks
  • Lleva las actividades en vivo a la Mac
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • AI & Machine Learning
    • Apple In-App Purchase
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • Localization
    • Maps & Location
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    • Documentation Archive
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Follow us on bilibili, LinkedIn, WeChat, and YouTube.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines