Alex Hay Profile picture
Jun 7, 2022 60 tweets 24 min read Read on X
Wow third-party developers can now implement powerful predicate filtering in Shortcut actions similar to the ones in Apple’s first-party actions #WWDC22 Image
‘Rich Text’ is listed here as a parameter’s possible input type, which wasn’t available previously when using an Intent Definition file 🤔 ImageImage
The new user prompts look really nice ImageImageImageImage
And being able to just pass in a SwiftUI view as a confirmation is interesting. Looking forward to playing around with this for displaying rich output to the user. Image
A better example of the new filtering ability in action Image
Ok starting to get my head around App Intents and putting together a rough project to experiment with the new features.
Really substantial new API to get to grips with but seems really powerful. Easier to start with but you can quickly pile on the complexity. #WWDC22
More details on rich text now being accepted as input Image
Would be great if we could have support for tappable links (or even Markdown!) in the IntentDescription

FB10168132 Image
Nice that we can now add keywords to actions in the library. Should make it easier for users to find the right actions quickly even if they type a different search term.

You can also add custom categories so that when the user taps on an app, all actions are grouped accordingly. ImageImage
This is awesome.

The new Shortcuts ‘snippets’ act like medium/large widgets so you can embed multiple links in them.

They don’t disappear when you tap a link & they don’t lock up the screen.

Just wish you could minimise them like a rich notification!
This also means you can run other shortcuts from a snippet.

You could create a rich menu from images or tap on a chart to open to a specific place in an app or… whatever you want really.

Lots of exciting possibilities here!
It’s also less than 20 lines of code to create an action in Shortcuts that shows a snippet when run 🤯 Image
Confused if this image parameter in the new App Intent is equivalent to selecting ‘Image’ as the file type in the Intent Definition file? ImageImage
With a file parameter defined in the Intent Definition file I can long press to select a variable whereas I can’t with the new method (only tap to open the file picker).

Doesn’t look like that’s a behaviour you can configure 🤔
The new SwiftUI-like ParameterSummary API with Switch & Case is really clever.

Allows for lots more flexibility in presenting conditional parameters than the previous system. Image
Here’s what that code looks like in the Shortcuts app
Not sure if it’s something I’m doing wrong but inputOptions on String @Parameters don’t seem to have any effect.

In the example below the keyboard for the text field in the summary remains lowercase & the property below it isn’t multi-line 🤔

Filed as FB10200372 ImageImage
What would the correct syntax be for a conditional ParameterSummary based on a Bool parameter? Image
I guess nested ParameterSummaries aren’t supported?

The code below builds OK but the Shortcuts action is displayed as if there is no summary provided. ImageImage
Snippet text colours don’t render correctly when Dark Mode is enabled.

For example Color.primary should be light on dark background.

(FB10209882) ImageImage
I think a custom entity’s ‘typeDisplayName’ is what determines how it is displayed in the Shortcuts app but I haven’t managed to get it working yet.

I thought this one may have been a clash with Apple’s own type but it doesn’t make a difference if it’s something unique. ImageImageImage
Hitting a wall with custom entity queries. 🥶

When I conform to EntityQuery there’s some automatic filtering done based on the display name, which works.

But when I conform to EntityStringQuery so I can match books by title/author, the ‘matching string’ func is never called. ImageImage
I think it’s probably something I’m doing wrong but I’ve filed it as FB10213109 in case it’s not!
This action shouldn’t be shown in the Action Library if there’s no query defined that conforms to EntityPropertyQuery should it? Image
Being able to easily add a SwiftUI view into a confirmation prompt is so nice!
Shortcuts responses can be so much richer and more visual now. Image
Am I supposed to be referencing the parameter or parameter value here?

The sample code is giving me mixed messages 🤔 (FB10235570) ImageImage
The difference in creating a ‘hello world’ Shortcuts action on iOS 15 vs iOS 16.

Hopefully this drives a lot more developer adoption. Image
In iOS 16 you can display rich sectioned lists as options for parameters using DynamicOptionsProvider.

developer.apple.com/documentation/…
Would be great if we could use an ‘IntentColor’ type as a parameter value & have the ColorPicker shown as a prompt.

Would work the same as the ‘Font Colour’ parameter in the ‘Overlay Text’ action.

(FB10299790) ImageImageImage
In AppIntents can I use a custom Type that isn’t an AppEntity?

I don’t want it to have a ‘Find’ action or perform a lookup when tapping the parameter.

Can I create a new custom Type that conforms to DisplayRepresentable or is that not supported?
String array parameters that aren’t included in the ParameterSummary don’t currently have title labels. These are 3 different parameters but the user can’t tell which is which.
(FB10358050) Image
Parameterising SwiftUI views and then being able to render them (cross-platform!) to an image using the new ImageRenderer API is really fun.
Really nice that you can present categorised values from an enum along with images 😍
You can get some fun effects with the new Remove Background action.

Here I’m just tinting and blurring the background then overlaying the extracted foreground.
There seem to be some caching issues with the Shortcuts app not reflecting changes made to App Intents until the device is rebooted.

Wish we had a ‘Rebuild Shortcuts Index’ or similar in the developer settings menu.

(FB10428858) Image
Shortcuts portrait mode Image
Doing some experimenting & I think there are some interesting uses for Focus Filters + Shortcuts 👨🏻‍🔬

In this example you can enter text when setting up a Focus then use a Shortcuts action to retrieve it from whichever one is active 👀

What else would you want from Focus Modes?
A small detail but with App Intents, actions that output a Bool now do so correctly.

Previously a Number would be returned (1 or 0) and the user would have to select Bool as the type before using it. Image
You can add a ‘description’ to a Parameter but I don’t think it shows in the UI.

It would be great if adding a description added it to the action’s description page.

So in this example, it would show as:

Scale
Decimal (optional) Increase the size of the blur

(FB10493576) ImageImageImage
It would also be nice if we could provide an ‘incrementBy’ value to a Double Parameter presented using the .stepper DoubleControlStyle.

In the example below each tap of the stepper button would increment or decrement by 0.25 rather than the default 1.0.

(FB10493472) Image
DisplayRepresentation systemImages don’t render in a lighter colour when using Dark Mode (on the Mac)

(FB10510606) ImageImageImage
Would be great if someone could take a look at this one - custom entities presented with a DynamicOptionsProvider always have a nil value in the perform method.

I’ve attached a very simple project to demonstrate the issue.

(FB10512365)
To return a custom type from Shortcuts without having the ‘Find Entity’ action & queries, you can conform your type to TransientEntity instead of AppEntity.

You can still prompt with a list of these objects in a parameter using a DynamicOptionsProvider.

developer.apple.com/documentation/…
Installing an app via Xcode works perfectly and shows all the actions in Shortcuts but installing the exact same build via TestFlight currently doesn’t show any actions at all.

Probably an early beta issue unless I’m missing something 🤔
This suggestion to explicitly mark the App Intents as public fixed the issue for me
Fixed in dev beta 3!
This bug was driving me crazy - I thought it was the nested conditionals that was causing the summary not to render but it was actually… the *comments* in the code!? (FB10208191)
Stumbled across the bug above whilst making a project to test this one where the result view doesn’t refresh to show the latest output on repeat runs of the shortcut (FB10208191)
As of dev beta 3, we can now add descriptions to parameters which show up in the action’s info panel 😍 ImageImage
Presenting enums from a parameter either doesn’t show the subtitle or shows it next to the option (depending on whether you’re using an optionsProvider).

I’d prefer if it looked more like the title/subtitle style in the list UI, rather than like an action sheet.

(FB10601834) ImageImageImageImage
Seems there’s a problem with Shortcuts on Mac seeing App Intents I’m adding.

I’ve added 3 new ones which won’t show. Deleting older ones won’t remove them from the action list.

The same ones show & run on the phone fine.

Restart, clean build, trash derived data not helping 🤔
On beta 3 I’m seeing all images rendering incorrectly from DynamicOptionsProviders. Doesn’t matter if they’re initialised with image data or a symbols with tint colours, they always appear blue. Don’t think this was an issue on beta 2.

(FB10666203) Image
Would be great if we could also initialise a DisplayRepresentation.Image using an SF Symbol and a tint colour from an NSColor or SwiftUI Color on the Mac.

(FB10666820) Image
Fixed in dev b3
There’s lots of really helpful example code dotted throughout the App Intents source - hopefully some of this makes its way into the documentation towards release Image
Not sure if this is the correct way to declare Measurement properties - they don’t seem to show up in the result object’s properties list in Shortcuts 🤔 ImageImage
Doesn’t like them in the PropertyQuery action either Image
Not sure if intentional but I can’t use enum AppEntity properties as filters in a ‘Find Entity’ action.

In this case I would like ‘Activity Enum’ to show in the list of filterable properties & when the user taps the value, the enum values should be listed

(FB10717279) ImageImageImage
Enums & Measurement issues aside… it’s so powerful!

Going to be a fantastic way to fetch workouts in your shortcuts - filtering by activity, energy burned, distance, temperature, duration & so on 🔥
It seems running a function that throws an error displays the error’s message correctly when run in an App Intent’s ‘perform’ method but not when thrown from an App Entity’s ‘entities’ method (in a query that conforms to EntityPropertyQuery).

God that’s a mouthful…

FB10721414 ImageImage

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Alex Hay

Alex Hay Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(