鳝鱼吃什么食物| 胃炎吃什么食物好得快| 结膜炎用什么眼药水效果好| 二氧化碳低是什么原因| 熬粥用什么锅好| 性病都有什么| romoss是什么牌子| 辅酶q10什么时候吃| 什么时候天黑| 急性上呼吸道感染是什么引起的| 医德是什么| 子宫内膜薄有什么影响| 炭疽病用什么农药最好| 眼神迷离是什么意思| 白参是什么参| 金秘书为什么那样| 产检挂什么科室| 这是什么动物| 喉咙有烧灼感吃什么药| hummel是什么牌子| 蜂蜜有什么作用与功效| 做包子用什么面粉好| 减肥早餐吃什么最好| 异烟肼是什么药| 羊是什么结构的字| 为什么会岔气| 菊花代表什么象征意义| 心服口服的意思是什么| 人活着意义是什么| 什么原因导致宫外孕| 羊和什么生肖最配| 脾胃虚吃什么调理| 下海是什么意思| 半夜尿多是什么原因| 衾怎么读什么意思| 远香近臭是什么意思| 糖类抗原199偏高是什么原因| 螯合是什么意思| 做梦梦见搬家是什么意思| 肉刺长什么样子图片| 交尾是什么意思| 还替身是什么意思| 虾肚子上的黑线是什么| 颈椎曲度变直是什么意思| 建档需要做什么检查| 什么时候征兵| hr是什么| 大象又什么又什么| 强光斑是什么意思| 思想包袱是什么意思| 纵容是什么意思| 错峰是什么意思| 血脂高看什么指标| 圣诞节送什么好| 医院三甲是什么意思| 澳门有什么好玩的地方| 文气是什么意思| 香港脚是什么| 人造奶油是什么做的| 糖耐筛查主要检查什么| 魅可口红属于什么档次| 生辰八字查五行缺什么| 老年性阴道炎用什么药| 淮山是什么| 肉便器是什么意思| 彩字五行属什么| 胃病能吃什么水果| 喝茉莉花茶有什么好处| 小叶苦丁茶有什么作用和功效| 脖子长痘是什么原因引起的| 小肠换气吃什么药| 哭得什么| 为什么喝牛奶会拉肚子| 干支是什么意思| 骨折吃什么消炎药| 吃枸杞有什么好处| 属鼠的是什么命| 豆柏是什么| 紫色芒果是什么品种| 男性检查hpv挂什么科| 命犯桃花是什么意思| 幼儿急疹吃什么药| 辣木籽主治什么病| 扁桃体肥大吃什么药好得快| 头晕冒冷汗是什么原因| 心三联是指什么| 5月21日是什么星座| lof什么意思| 五行缺金有什么影响| 吃红萝卜有什么好处| 阴道口痒是什么原因| 哺乳期上火了吃什么降火最快| 最好的红酒是什么牌子| 泻盐是什么东西| 雷替斯和优甲乐有什么区别| 书的五行属性是什么| 绿豆什么时候收获| b什么意思| 喝酒不能吃什么药| 取笑是什么意思| 三七粉什么颜色| 包粽子用什么米| 牙齿痛吃什么药最管用| 什么是同人文| 一什么黑影| 膀胱炎是什么症状表现| 臃肿是什么意思| 栎字五行属什么| 大众什么车最贵| 郁郁寡欢什么意思| 拘挛是什么意思| 厄警失痣是什么意思| 炉中火是什么意思| 摆摊卖什么好| 菩提子是什么树的种子| 手机为什么突然关机| 鸭嘴鱼吃什么食物| 葡萄胎是什么| 蜂窝组织炎是什么病| 六月十一是什么星座| 头皮起疙瘩是什么原因| 吃什么水果败火| 没什么打什么| 神机妙算是什么意思| 子午相冲是什么意思| 指日可待什么意思| 什么人容易得小脑萎缩| 梦见挖野菜是什么意思| 经常口腔溃疡吃什么维生素| 坑坑洼洼是什么意思| 嘴巴干是什么原因| 孕妇口腔溃疡能用什么药| faleda是什么牌子的手表| 1994年属狗是什么命| 五塔标行军散有什么功效| 什么叫青光眼| 甲硝唑吃多了有什么危害| 男蛇配什么属相最好| 丙火是什么意思| 清点是什么意思| 宫腔内囊性结构是什么意思| 椎体终板炎是什么病| 10月17日什么星座| 湿疹抹什么药膏| 书犹药也下一句是什么| 一动就出汗是什么原因| 生物制剂是什么药| 积水是什么意思| 吃过期药有什么危害| 什么好| 疑虑是什么意思| 鹿晗有什么歌| 肺气肿吃什么食物好| 血糖高有什么症状| 胆囊炎适合吃什么食物| 哺乳期吃什么水果好| 梦见小葱是什么意思| 形而上学什么意思| 断更是什么意思| 我国的国球是什么球| 孕妇什么水果不能吃| s牌运动鞋是什么牌子| 宝宝拉黑色大便是什么原因| 菱角是什么意思| 财政部部长什么级别| 豆腐有什么营养| 膝盖疼挂什么科| 女人每天吃什么抗衰老| 胳膊上的肌肉叫什么| 阳光照耀是什么意思| 痛风是什么原因引起的| 200年属什么生肖| 炖牛肉放什么佐料| 月经量多吃什么药调理| bb霜是什么| 高铁与动车的区别是什么| 八哥吃什么食物| 覆盆子有什么作用| 均匀是什么意思| davena手表什么牌子| 红细胞压积是什么意思| 百福图挂在家里什么位置好| 红面是什么面| 妥瑞氏症是什么病| 什么病会引起牙疼| 现代是什么时候| 犒劳自己是什么意思| plover是什么牌子| 紫苏有什么功效| 夏天喝什么| 送哥们什么礼物好| sad什么意思| 蜂蜜水什么时候喝比较好| lof是什么意思| 韭菜苔炒什么好吃| 为所当为什么意思| 11月18号是什么星座的| 骆驼吃什么食物| 塞翁失马什么意思| 木可以加什么偏旁| 松鼠的尾巴有什么作用| 马眼是什么| 杀子痣是什么意思| 肾结石有什么表现症状| 没有痔疮大便出血是什么原因| 煞气是什么意思| 小腹痛是什么原因| 溴隐亭是什么药| 月经不调挂什么科室| 是什么星座| 例假为什么第一天最疼| 温州人为什么会做生意| 一月十二号是什么星座| 秋葵有什么营养价值| 闭关什么意思| 双鱼男喜欢什么样的女生| 肚子两侧疼是什么原因| 才高八斗什么意思| 乏力是什么意思| 超脱是什么意思| 人得猫癣用什么药| cm3是什么单位| 神经紊乱会出现什么症状| 爱戴是什么意思| 互诉衷肠是什么意思| 尿常规白细胞偏高是什么原因| 支数是什么意思| bnp是什么| 脾主什么| 胃穿孔有什么症状| 月经咖啡色是什么原因| 经常眩晕是什么原因| 口腔溃疡吃什么好的快| 茉莉花茶属于什么茶类| 七月一日是什么节日| 儿童喉咙痒咳嗽吃什么药| 老鼠疣长什么样子图片| kdj是什么意思| 长期拉肚子是怎么回事什么原因造成| 老年人出虚汗是什么原因引起的| 淋巴结长什么样| 湿疹用什么药膏最有效| 芸字五行属什么| 间隔旁型肺气肿是什么| 双肺纹理增多增粗是什么病| 冠脉cta是什么检查| 什么是hr| 10年是什么婚| 纯原是什么意思| 孕妇可以吃什么零食| 吹风扇感冒了吃什么药| 兔和什么生肖最配| 小孩小腿疼是什么原因引起的| 什么叫阴虚什么叫阳虚| poems综合征是什么病| 冠状动脉ct检查什么| 月子期间可以吃什么水果| 震字五行属什么| 什么水果对胃好更养胃| 束缚什么意思| 糖类抗原ca199偏高是什么原因| 3月12日是什么星座| 老人爱睡觉什么征兆| 什么的清香| 百度

View in English

  • Global Nav Open Menu Global Nav Close Menu
  • Apple Developer
Search
Cancel
  • Apple Developer
  • News
  • Discover
  • Design
  • Develop
  • Distribute
  • Support
  • Account
Only search within “”

Quick Links

5 Quick Links

Videos

Open Menu Close Menu
  • Collections
  • Topics
  • All Videos
  • About

More Videos

  • About
  • Transcript
  • 病理科是干什么的

    百度 “我国新型政党制度的一个重要优势是能够通过科学决策‘画出同心圆’。

    Learn the principles of the App Intents framework, like intents, entities, and queries, and how you can harness them to expose your app's most important functionality right where people need it most. Find out how to build deep integration between your app and the many system features built on top of App Intents, including Siri, controls and widgets, Apple Pencil, Shortcuts, the Action button, and more. Get tips on how to build your App Intents integrations efficiently to create the best experiences in every surface while still sharing code and core functionality.

    Chapters

    • 0:00 - Introduction
    • 1:29 - Friction versus flow
    • 5:44 - Understanding the framework
    • 8:06 - Building the code

    Resources

    • Accelerating app interactions with App Intents
    • App Intents
    • Creating your first app intent
    • Forum: Machine Learning and AI
    • Making actions and content discoverable and widely available
      • HD Video
      • SD Video

    Related Videos

    WWDC24

    • Bring your app to Siri
    • Design App Intents for system experiences
    • Explore machine learning on Apple platforms

    WWDC23

    • Explore enhancements to App Intents
  • Search this video…

    Hi! Welcome to Bring your app’s core features to users with App Intents. I’m Christopher Nebel, an engineer on the App Intents team.

    This is my app. There are many like it, but this one is mine. Actually, it’s sample code; it’s available from the developer site. It’s a catalog of trails; we’ll be seeing it throughout this video. Just, work with me here. Anyway! This is my app, and it is awesome. People tell me that when they’re in it, it’s a delight to use. What about when they’re not in it? It’s mostly invisible, it’s just a box on their Home Screen? Not necessarily! With the right code, I can lift my app’s features out of that box and elevate them to other places in the device, so that people can perform actions from my app directly from Spotlight, or by speaking to Siri.

    Or they can add information in a widget to their Home Screen.

    Or add actions and status to Control Center.

    So my app will continue to delight people even when they aren’t in the app.

    This is what App Intents and the features that it powers delivers. How does that work? Well, you’re in the right place to find out. I’m going to talk about improving flow when using your app, and a family of system features that help you do that.

    What App Intents is, and how it fits in with those features, and how to get started building App Intents for your app.

    An important part of a delightful experience is flow. In psychology, that’s the melding of thought and action. Whatever you think to do, you do it, effortlessly. On a device, that means the next thing you need is always nearby and easy to get to. If you have distracting extra steps in the way of your flow, that’s called friction. Metaphorically, anything that resists getting things done. The same metaphor shows up in lots of other expressions: Things with high friction are rough. You get stuck. They’re a real drag, man. Things with low friction are fluid. They’re like a well-oiled machine. They’re smooth. A little friction can be a good thing, don’t get me started on completely frictionless surfaces but generally, you want to reduce friction wherever you can. Friction doesn’t have to be a single big barrier. Often, it’s a small bump that you hit over and over. An example when using your device is switching apps.

    Your app defines a little world, its own box, that you have carefully crafted, and within that app, it’s perfect. The catch is that people don’t use just one app to get things done. They use many. What happens when they need to move between boxes? Because each of them is in their own box. And by default, the only way to see or do anything in a box is to go into it, which means now you can’t see or do anything in any of the other boxes. You have to leave your current box and go into another one. That is, you have to switch apps.

    And switching apps isn’t really hard, but it’s not free. It takes time and thought while you navigate there and back. That’s friction. What if the device understood what’s in your box, your core features? Then, it could present them higher up, outside your box, and make them quicker and easier to get to. There’s a whole family of system features based on this idea, making the experience of using your device flow. Let’s look at a few examples, all of which I’m going to build later.

    These are based on my example app, which shows a catalog of trails in the area, with various details about them.

    Some features help me get to the right place in the app faster, such as searching in Spotlight.

    Say I’m at the Home Screen, and I want to look at my pinned trail. So I trigger Spotlight. Before I even type anything, Spotlight Suggestions guesses that I want my example app and offers the app shortcut that I need. Imagine that it hadn’t guessed that, so I have to type: e, x, a. Now it’s sure I want my example app, so there it is as a Top Hit, with the app shortcut even more prominently placed.

    Or, from anywhere, I could have just said what I wanted to Siri.

    Some features don’t just make it easier to switch apps. They make it so I don’t need to switch apps in the first place. Let’s say I want to keep an eye on the conditions for my favorite trail.

    Instead of opening the app every time I think of it, I can add that information to my Home Screen with a widget. Now I can glance at it as I’m doing other things. I could add it to the Lock Screen, and then I wouldn’t even need to unlock my phone.

    Or I can add a custom control to Control Center, which I can reach while using any other app.

    There are many other features like these, and we keep adding them. Last year, we added the Action button. This year, we’re adding Camera capture, Apple Pencil Pro: squeeze, and more.

    All of them elevate your app's features out of their box, to become part of the whole device experience, and streamline the flow between thinking I want to do this and it’s done. There's an important distinction among these features: Who chooses what to elevate? With features like Spotlight, you, the developer, choose. You highlight important actions in your app, and the device presents them automatically in the right spots. Likely actions from your app are always close by, no matter where people are on their device, giving them that sense of flow.

    With features like Widgets and Controls, people choose. You provide flexible components, and then people can choose precisely the ones that matter, and build the right work flow for them. In other words, they can personalize their experience of your app making their device an extension of, and even an expression of, themselves. That’s good for them, and it’s good for you, the app developer. Because the more people can mold your app to fit themselves and their lives, the more likely they are to keep using it.

    At this point, you might be saying, this sounds great, I want my app to flow, what do I do? Glad you asked! The answer is, you adopt App Intents. And you say, wait, what? I thought we were talking about Siri, and Control Center, and all those other cool features. And I say, we are. Allow me to explain.

    App Intents is not a feature in itself. It’s a common foundation for building features. All these features we’ve talked about, Siri, Spotlight, Shortcuts, and so on, have a common theme: They take the core features from inside your app, actions and content that are meaningful to someone using your app, and present them outside your app.

    To do that, you need to expose your app’s core features in a way that the system can understand. App Intents is the framework to do that. It handles two big parts. First, it lets you define what your core actions and content are, so system features like Siri and Spotlight know what they can present. Second, actually presenting something means a bunch of back and forth communication between your app and the presenter. For example, if someone tells Siri to do a thing in your app, Siri has to send a message to your app to do the thing, and then your app has to send a message back saying that it did it, and here are the results.

    App Intents handles that communication, so you can concentrate on implementing the actual behavior of your features. And once you’ve done that to support one system feature? That same work is useful across a range of system features, because they’re all based on App Intents. So you can share code between them, and even support several features with the exact same code.

    There are three top-level things you’ll write, and I’ll show how in the next section.

    Intents perform an action, like Opening a view or Starting a hike. They’re the commands, or verbs, in your app.

    Entities are objects, like a Trail or a Collection. They’re the nouns. If intents are verbs, and entities are nouns, then App Shortcuts are sentences. They package together a verb and a noun or a blank to fill in a noun, and whatever other options are needed into a single thing that describes an important function of your app, something that you know anyone who uses your app will want to do.

    Features like Spotlight and the Action button will then offer that function, that sentence, so people can do it quickly and easily.

    Together, these define how your app appears across the device. Now that you have a general idea, let’s write some code.

    I’m going to add some features to my app to help it flow. Five of them, in fact: A simple Shortcuts action with no parameters. A Parameterized Shortcuts action. A Home Screen Widget. A Control Center control. And app shortcuts for Spotlight and Siri. That sounds like an awful lot, but they’re all based on the App Intents framework, and that’s going to help me share a lot of code between the features. Let’s get started.

    The Shortcuts app is a powerful tool where people can explore, combine, and remix actions to create their own custom shortcuts. For example, my teammate loves mountain biking with his daughter, so they used the actions from my app to build a custom shortcut that picks a random biking trail in an area.

    As the developer, I might not prioritize this feature, it’s kind of specific. But I can offer flexibility in the form of Shortcuts actions, so they can build it for themselves, and tune it to be exactly what they want.

    I recently added a feature to Pin a trail to the top of the list. That way, when I’m planning a trip there, I can open its details quickly, so I can answer questions like how do I get there, or can my friend bring their dog? Works great, but I want to be able to get to that trail quickly even if I’m not currently in the app, so let’s make a Shortcuts action that opens the pinned trail details in the app.

    When I’m done, it’s going look like this in the Shortcuts app.

    In the App Intents framework, a Shortcuts action is an intent, all intents appear by default as actions in the Shortcuts app.

    An intent is a type that conforms to the App Intent protocol.

    It has two required pieces: A localizable title, which will appear as the name of the action, and a perform method, which does the action.

    Intents should always be actions that are meaningful to someone who uses the app. Here, OpenPinnedTrail not internal implementation.

    Perform methods always have a result, but the result may be empty, as it is here.

    For this intent, I want it to open the app when it runs, because I’m showing a view in the app. App Intents will handle that for me if I tell it to, which I do with openAppWhenRun like this.

    An intent can also have extra parameters, extra information needed to do its job. This intent doesn’t need any, but I’ll come back to one that does.

    And that’s it! My new intent shows as an action in the Shortcuts app library.

    If I make a shortcut with this action, I can run it in the Shortcuts app. I can take that one step further and add it to my Home Screen.

    If I tap it, it runs, and my app opens with the pinned trail details, just like I wanted.

    That’s not bad, but I also want an action that lets me pick the trail to open, so I can make a shortcut that opens a particular trail, or that asks me for a trail when I run it.

    To do that, I need to make an intent with a parameter. This is going to look very similar to the first intent.

    In fact, I’m going to start by cloning the first intent and changing its name. Intents that open their parameter in the app have a special protocol, OpenIntent, so I’m going to add that.

    Open Intent implies openAppWhenRun, so I can delete that.

    And, I need to add the parameter that the protocol defines.

    A parameter is just a normal property marked with @Parameter so you can add extra metadata like a localizable title.

    I said it should be a trail. Trails are a core content type in my app, so I’ll make it a trail entity.

    Two things to remember here: First, entities should be things that are meaningful to someone who uses the app. So this isn’t a database row, or whatever my implementation is, it’s a trail. Second, a parameter that refers to an entity should be an entity, not data describing one. So this isn’t a trail name, or UUID, it’s a TrailEntity.

    I update the perform method to navigate to the parameter. And I’m done, except for the part where I have to define the TrailEntity.

    Fortunately, that’s not very hard. An entity is a type that conforms to the AppEntity protocol. You can conform your model type directly. This works well if your model is small enough to all fit into memory at once, so all the necessary instances already exist. Or, you can make your entity its own type that merely refers to your implementation. This is useful if you only create model instances as you need them, or if your model instances have expensive properties that aren’t needed for your intents.

    In this example, I‘m going with the second approach, so TrailEntity will refer to my underlying model type Trail.

    An entity may have Properties here, the trail name. It’s very similar to a parameter, but it’s on a content object, not a command.

    An entity must have three things: A display representation, so the device can do things like draw them in a menu, a persistent identifier, and a query.

    Right. What’s a query? Before I tell you what a query is, I should tell you what a query does. A query turns questions asking for entities into actual entities.

    And choosing a value for the intent parameter is going to ask two questions: First, what entities are there? So the device can show a list of options someone can pick from.

    When they pick one, it’s going to save the ID for that entity. Then, when it’s time to run the intent, it sends that saved ID, and the query needs to answer the second question: What entity has this ID? Given that answer, it can fill in the intent parameter, so your intent code gets an entity, and not just an ID. What does that code look like? A query is a type that conforms to EntityQuery. There are several different ways to ask for entities, not just the two I already mentioned, what options and what has this ID, but also searching for a string, searching by predicate, and so on.

    So EntityQuery has several sub-protocols, one for each kind of question.

    The what entities are there question, can be handled by EnumerableEntityQuery, which defines a method allEntities, like this. This is the conceptually simplest form of query. App Intents can derive the more complicated ones from this, if you build with the iOS 18 SDK. Of course, it only works if you can actually return all your entities at once, so your whole model has to fit into memory. If that’s not the case, or if you can do a better job than the automatically derived queries, then you should use one of the other query protocols. But this example is simple enough for it to work.

    The what entity has this ID question is answered by EntityQuery itself, with this method, entities(for:).

    Together, these handle everything parameter configuration needs to work.

    And now my intent is ready to run. But there’s one more thing I should add, which is a parameter summary.

    Without one, my intent looks like this in the Shortcuts app. This works, but it’s hard to read and understand, because the trail that it’s going to open is below the fold.

    A parameterSummary, is a natural language sentence that describes what the intent will do, including the values of all the essential parameters, in this case, the trail to open. Now it’s easier to see what this intent does, and it’s readable as I edit the parameter.

    Let’s see it in action. When I tap the Trail placeholder, I get a sheet to pick a trail. The query provides the options, and powers searching. When I pick one, it appears inline so I can immediately read what this action will do when it runs. That’s the parameter summary at work.

    I actually don’t want to choose a trail now. I want to choose one when it runs. So I’ll clear that parameter and save the shortcut to my Home Screen.

    Now, when I tap the shortcut, I get a similar picker, again, powered by the query, and it works straight from my Home Screen or anywhere I can trigger the shortcut.

    Shortcuts actions are the ultimate in adding flexibility to your app. People will build them into all kinds of workflows that you never imagined. Let’s look at a more focused form of flexibility, that lets you view information at a glance: A widget. Most details about a trail don’t change often, if ever. It’s not going to move to a new location. Probably. We do have earthquakes.

    Conditions, however, can and do change routinely, so it would be handy to keep an eye on them.

    That’s a perfect use for a widget. They’re designed for glanceable information. I could make a widget that just shows the details of my pinned trail, but I want to keep an eye on a few different trails, so I can choose whichever one is nicest. To do that, I need to make my widget configurable so I can set which trail to show. That means my widget is going to have a trail parameter, much like my Open Trail action.

    In order to make a widget, I need a widget definition. This isn’t a WidgetKit video, so I’m skipping a number of details like the view and timeline provider. If you want to know more about that, refer to the WidgetKit documentation, and for more details about how widgets work with App Intents, check out "Explore enhancements to App Intents" from WWDC23.

    The relevant part here is the body. And especially the intent parameter, where I set the configuration intent type for this widget.

    The configuration intent, is an intent that conforms to WidgetConfigurationIntent. Funny how that works.

    Like all intents, it needs to have a title.

    And I said I wanted this widget to be configurable with a trail, so I’ll add a parameter.

    It’s supposed to be a trail, and I already defined a trail entity for my open intent. Can I re-use that? Funny you should ask. Yes, you can.

    I’m making it optional, so it can be empty when the widget is added to the Home Screen, but it’s otherwise the same type as the parameter in the Open Trail intent. Now, I have a trail-conditions widget that’s configurable for any trail, so I can add as many as I need. The trail entity and its query that I already wrote handle picking a value for the configuration, so I didn’t need to write that again.

    That was remarkably straightforward, so let’s do another one: A Control Center control, which have a new API in iOS 18.

    Like the widget, I want the control to be configurable with a trail. When tapped, it should open that trail’s details in the app.

    This is only going to cover the App Intents-related parts of Controls. For the full Control details, see “Extend your app’s controls across the system”. With that in mind, let’s get started.

    The basic outline of a control is that it’s a special type of widget, ControlWidget. Which has a body that defines what the control looks like and what it does.

    A configurable control, which is what I’m aiming for, is configured using an App Intent. Much like a configurable widget, so I add an AppIntentControlConfiguration.

    I said it should act as a button, so I'll add a ControlWidgetButton.

    This is the basic shape for a configurable button control. I still need an intent type to hold the configuration so I can build the button contents, and an intent instance to handle when the button is tapped.

    Let’s think about this for a second. I said I wanted the configuration to have a trail parameter. That sounds kind of like the Open Trail intent I made earlier. Can I re-use that? You bet I can. The one thing I need to change about OpenTrail is to declare that it conforms to ControlConfigurationIntent. That’s an extension, and doesn’t require anything that the intent doesn’t already have, so the body is empty.

    Once that’s done, I can fill in the type and use the configured instance of that type to build the image and text for the button.

    And here’s the really clever bit. I still need an action, which is an intent instance, and it should open the configured trail. Again, that sounds like OpenTrail. But, I don’t need to make a new OpenTrail instance, because I already have one as the configuration intent. I can simply pass that as the action, because it already has the Perform method I need and is configured the way I want. Let’s see it work.

    This is the new configuration mode for Control Center. I’ve already added the new control at the lower left, here, and configured it to open the Monterey Bay Coastal Trail. If I stop editing, the control is now live, so if I tap it, the intent runs, and my app opens to the trail details I configured.

    Now, I’ll make one of my app’s actions available automatically in Spotlight and Siri, opening the details of the pinned trail. To do that, I need to make an App Shortcut. An App Shortcut is a wrapper that you, the developer, create around an intent that highlights it as an important function of your app.

    Various features will then offer that App Shortcut such as Spotlight, the Action button, and Apple Pencil Pro, without needing your app to be running or even have run at all. Let’s look at the code for that.

    I define a single AppShortcutsProvider with a static member, which is a list of app shortcuts. An AppShortcut wraps an intent. Here, the OpenPinnedTrail intent I created earlier.

    Notice that this is an intent instance, not a type. That means that I can pre-fill some or all of the parameters here. So I could take a very general intent with lots of parameters, and wrap it as an AppShortcut that does something very specific. It will prompt for any unfilled required ones when the shortcut runs, so it works either way. It depends on what experience you want to provide. This intent doesn’t have any parameters, so the parentheses are empty.

    Since App Shortcuts are available from Siri, there’s a list of phrases to speak, each of which must contain the app name.

    And for places where it’s displayed visually, such as Spotlight, a title and image.

    Notice one thing that’s not here: Any sort of registration code. The App Intents framework automatically detects the provider and handles registration, so my App Shortcuts are available as soon as the app is installed.

    With that, the App Shortcut now appears in Spotlight.

    And can be spoken to Siri.

    Both Spotlight and Siri are handled automatically; someone using their device doesn’t need to do anything more than install the app. But, if they want to customize their device, App Shortcuts are also available: In the Action button and Apple Pencil Pro. So that’s four features for one piece of code. And if you have existing App Shortcuts? They already work with Apple Pencil Pro, same as they automatically worked with the Action button last year.

    This is looking good, but the Siri interaction isn’t quite right. First, it’s going to show a view which means I have to at least be looking at my device. Second, it’s going to open the app, which is going to bounce me out of whatever app I’m currently using. So let’s replace that intent with a slightly different one that returns the information instead.

    I’ll make an intent, but this one won’t Open the pinned trail. It will show it in a snippet, and speak it if the user isn't looking at their screen, or doesn’t have a screen, like a HomePod or AirPods.

    I’ll start with a stub perform method. Step one is clearly getting the pinned trail. But what’s step two? How do I show or speak information without using my app? I use the result.

    The result of a Perform method isn’t just a value. It’s a rich combination of things, including dialog that Siri can speak and a view snippet it can show.

    If I say that my result conforms to ProvidesDialog and ShowsSnippetView, I can use a different method to create the result that takes dialog and a view. I can supply just dialog or just a view if that makes sense, but here I’m going to do both.

    I’ll write what I want Siri to say, which may be different from the text in the snippet. I’m using an interpolated string here for convenience, but this parameter is actually an Intent Dialog instance, which allows separate Full and Supporting dialog if you need it.

    And I supply a SwiftUI view. I’ll spare you the exact details of my view and use a separate function to get it, but I could have put it inline, using a trailing closure with a view builder expression.

    In either case, the view is archived like a widget, so it can be relayed to Siri. So you can use any SwiftUI features that widgets support.

    Now, when I ask Siri, it will show me the pinned trail conditions in a snippet, if I'm looking at the screen. When I dismiss it, I'm right where I left off, so I don't have to find my way back. If I'm not looking at the screen, Siri will speak the dialog to me. If my phone is in my pocket because I'm busy looking for my boots, I can ask my HomePod across the room for the conditions and I don't even need to take my phone out.

    Ok, wow. I just added a redonkulous number of features to streamline how people can use my app, and it wasn’t even that much code. This is what App Intents does. It lets you express your core concepts once, and then re-use them across many related features. Wrapping up: You can improve flow when using your app. People will get things done faster, they’ll enjoy it more, and they’ll be able to tune how they use your app and build it into their lives. To do that, adopt features like Siri, Shortcuts, widgets, and more, all of which let people use your app even when they’re not in your app. The way you adopt those features is to use App Intents, because it’s the foundation for all of them. That means you need to learn fewer different APIs, and you can share code between features.

    Want to learn more? Of course you do! Here are some great videos to watch next: If you’re still fairly new to App Intents and honestly, even if you're not see "Designing App Intents", on what makes a great App Intent. If you want to find out more about how App Intents work with Siri, see "Bring your app to Siri".

    If you already have App Intents and want to find out what’s new since last year, see "What’s new in App Intents".

    Thanks for watching, and we can’t wait to see what you do with App Intents!

Developer Footer

  • Videos
  • WWDC24
  • Bring your app’s core features to users with App Intents
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • App Extensions
    • App Store
    • Audio & Video
    • Augmented Reality
    • Design
    • Distribution
    • Education
    • Fonts
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning
    • Open Source
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Tutorials
    • Downloads
    • Forums
    • Videos
    Open Menu Close Menu
    • Support Articles
    • Contact Us
    • 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
    • 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
    Get the Apple Developer app.
    Copyright ? 2025 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines
    佯装是什么意思 脂肪肝轻度是什么意思 真相是什么意思 彩色多普勒超声检查是什么 袁崇焕为什么被杀
    hpl是什么意思 夜晚尿频尿多是什么原因 微针有什么功效 甲亢是一种什么病 小米粥配什么菜好吃
    小孩牙龈黑紫色是什么原因 师傅和师父有什么区别 肾结石都有什么症状 肚子里的蛔虫是什么意思 吃什么长头发
    一直干咳是什么原因 梦到扫地是什么意思 为什么会感冒 kids是什么意思 腿麻木是什么原因引起的
    净身是什么hcv8jop4ns1r.cn 苍苍什么helloaicloud.com 什么是回迁房hcv8jop5ns9r.cn 门静脉高压是什么意思hcv8jop2ns9r.cn 属牛幸运色是什么颜色hcv9jop6ns0r.cn
    菊花茶适合什么人喝hcv8jop3ns6r.cn 做面条用什么面粉hcv9jop4ns3r.cn 男孩适合学什么专业hcv9jop3ns0r.cn 肉字是什么结构ff14chat.com 养肝吃什么食物hcv9jop1ns4r.cn
    生加一笔是什么字hcv8jop4ns2r.cn 鱼加完念什么hcv9jop6ns6r.cn 气短挂什么科hcv8jop5ns0r.cn 脚底发热是什么原因hcv8jop3ns7r.cn 漏尿是什么原因hcv7jop9ns9r.cn
    一什么秧苗hcv9jop0ns0r.cn 真丝棉是什么面料hcv9jop2ns1r.cn 颈管细胞有是什么意思hcv9jop3ns4r.cn edm是什么hcv8jop6ns9r.cn 胎盘位于子宫前壁是什么意思xinmaowt.com
    百度