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
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven 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 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
  • Meet Focus filters

    Discover how you can customize app behaviors based on someone's currently enabled Focus. We'll show you how to use App Intents to define your app's Focus filters, act on changes from the system, and present your app's views in different ways. We'll also explore how you can filter notifications and update badge counts.

    To get the most out of this session, we recommend first watching "Dive into App Intents" from WWDC22.

    Recursos

    • Focus
    • User Notifications
      • Video HD
      • Video SD

    Videos relacionados

    WWDC22

    • Dive into App Intents
    • WWDC22 Day 1 recap
  • Buscar este video…
    • 4:57 - Implementing SetFocusFilterIntent

      // Implementing SetFocusFilterIntent
      
      import AppIntents
      
      struct ExampleChatAppFocusFilter: SetFocusFilterIntent {
      
          static var title: LocalizedStringResource = "Set account, status & look"
          static var description: LocalizedStringResource? = """
              Select an account, set your status, and configure
              the look of Example Chat App.
          """
      }
    • 7:02 - Defining your Parameters & Entities

      // Defining your Parameters & Entities
      
      import AppIntents
      
      struct ExampleChatAppFocusFilter: SetFocusFilterIntent {
      
          @Parameter(title: "Use Dark Mode", default: false)
          var alwaysUseDarkMode: Bool
      
          @Parameter(title: "Status Message")
          var status: String?
      
          @Parameter(title: "Selected Account")
          var account: AccountEntity?
      
          // ...
      }
    • 8:43 - Display Representation

      // Display Representation
      
      struct ExampleChatAppFocusFilter: SetFocusFilterIntent {
          // ...
        
          var localizedDarkModeString: String {
              return self.alwaysUseDarkMode ? "Dark" : "Dynamic"
          }
      
          var displayRepresentation: DisplayRepresentation {
              var titleList: [LocalizedStringResource] = [], subtitleList: [String] = []
              if let account = self.account {
                  titleList.append("Account")
                  subtitleList.append(account.displayName)
              }
              if let status = self.status {
                  titleList.append("Status")
                  subtitleList.append(status)
              }
              titleList.append("Look")
              subtitleList.append(self.localizedDarkModeString)
          
              let title = LocalizedStringResource("Set \(titleList, format: .list(type: .and))")
              let subtitle = LocalizedStringResource("\(subtitleList.formatted())")
      
              return DisplayRepresentation(title: title, subtitle: subtitle)
          }
        
          // ...
      }
    • 11:24 - Implementing Perform on your Focus filter

      // Implementing Perform on your Focus filter
      
      import AppIntents
      
      struct ExampleChatAppFocusFilter: SetFocusFilterIntent {
          // ...
      
          func perform() async throws -> some IntentResult {
              let myData = AppData(
                  alwaysUseDarkMode: self.alwaysUseDarkMode,
                  status: self.status,
                  account: self.account
              )
              myModel.shared.updateAppWithData(myData)
              return .result()
          }
        
          // ...
      }
    • 11:47 - Calling Current

      // Calling Current
      
      import AppIntents
      
      func updateCurrentFilter() async throws {
          do {
              let currentFilter = try await ExampleChatAppFocusFilter.current
              let myData = AppData(
                  myRequiredBoolValue: currentFilter.myRequiredBoolValue,
                  myOptionalStringValue: currentFilter.myOptionalStringValue,
                  myOptionalAppEnum: currentFilter.myOptionalAppEnum,
                  myAppEntity: currentFilter.myAppEntity
              )
              myModel.shared.updateAppWithData(myData)
          } catch let error {
              print("Error loading current filter: \(error.localizedDescription)")
              throw error
          }
      }
    • 13:27 - Set a filterPredicate

      // Set filterPredicate on an App context
      
      import AppIntents
      
      struct ExampleChatAppFocusFilter: SetFocusFilterIntent {
      
          var appContext: FocusFilterAppContext {
              let allowedAccountList = [account.identifier]
              let predicate = NSPredicate(format: "SELF IN %@", allowedAccountList)
              return FocusFilterAppContext(notificationFilterPredicate: predicate)
          }
      }
    • 13:53 - Pass filterCriteria on UNNotificationContent

      // Pass filterCriteria on UNNotificationContent
      
      let content = UNMutableNotificationContent()
      content.title = "Curt Rothert"
      content.subtitle = "Slide Feedback"
      content.body = "The run through today was great. I had few comments about slide 22 and 28."
      content.filterCriteria = "work-account-identifier"

Developer Footer

  • Videos
  • WWDC22
  • Meet Focus filters
  • 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
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    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.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines