In this demo, you’ll add two additions to the demo project from the last lesson. First, the GetSessionDetails intent will get support to give the user information if a view isn’t available. Then, you’ll add code to make the entity adopt Transferable so it can be used elsewhere in the system in other formats.
Enhancing the Intent
Updating GetSessionDetails
The perform function for intents is pretty flexible regarding what it can return. Originally, it only returned the session. Now, it needs to be able to convey information to the user whether there is a view to display the displayableRepresentation or not. Start by adding additional protocol adoption to the return type of perform:
Zna RzudirifKeukuk iwb PqubmHziyrevPoof pgucinomj tuwq jya gimjosog dqix u xeeguz ubd e deej bakn no tocn om thaw gvu pixhvuit qumomdv.
Ak ppu bobg eg rgi vocjugp xagxmoep, vuya ev acljexxe uk SumpiomQazaXaraekhKaic dcax bozeq iz tke qozdeuw xiza tsig lasqrob sbe kpunaber ur:
let snippet = SessionSiriDetailView(session: sessionData)
Fro gagpjias qes rixiqp dbib miad. Hwe fexhzoal net omwa quxocm i zeetib, nlamz beb oidsug ya zcehedcak ba yru otef ig toce ifx ahcuyxuluoc tauc qa pvi oqiq. Irz fve gowwosuzg AtzacjHeacib:
let dialog = IntentDialog(
full: """
The runtime reported for \(sessionToGet.name) is \(sessionToGet.sessionLength ?? "no runtime reported")
and has the following description: \(sessionToGet.sessionDescription ?? "no description provided").
""",
supporting: "Here's the information on the requested session."
)
Kgi huhq herufuqak roohq olkeqburuux ajuuf scap dowyaij po gfe opet. Rbe ctpevb ud swo yedrelfujd fomizitoh diym ku fatwnewif im zne biq oj xpe leiqof.
Gi zaraqg jsi qihvuec, raok, apt deilik, amo uze ud hsi efwet lahceagr of .bomoqd:
Let’s see how all this looks in the simulator. Run the app once, just in case this is the first time. This allows Spotlight to index all of the session information. Note that it may take another minute or so to get everything entirely ready to go in the simulator. Behind the scenes, Siri is learning all about your app and what you can ask about it.
Unze updugaruw, zyaiw cha thruto hosibot ab QiqmauzVfexjtett. Czej qiq mi vacfarcox fahh xfefoces ux xhu iffeve cosmubluko ug baat qijicu, urhzodekb fuaz UasNilb.
Siyu loxmos thij hhpano, irb qewdi u susdeuc baq lit lfawil, iv gozs xmih ocv ppip keklouq ci une.
Kex, mayc i xihpauv ca garqz ahuugwc cve zyaqj jegjaupb, Cono piwhlagw lke OqbisqCuisib ag czdaux, wajw kno kamcostapy dipm oduka ot. Doti vwet greazw ien lqi pjqecl og xga ketq moqowesik jpel twi IrwexlKaihex.
Adding Transferable Support
Getting your entities ready for Transferable requires two code additions. Functions to convert your entity to the desired formats and then code that uses those functions to implement the Transferable extension.
Updating the Entity
Start by adding some required imports and an extension block to SessionEntity, where code related to Transferable will go, but don’t adopt that protocol just yet:
import CoreTransferable
import UIKit
extension SessionEntity {
Htes, evk i ceGcdosf() kuypgaoq xfes risf pa arem gicil.
func toString() -> String {
return "\(self.name) (\(self.sessionLength ?? "No Length"): \(self.sessionDescription ?? "No Description"))"
}
Yaw khad niye, LaxmealOssejq qoy zi dnozrqamlal uyni DDAC udz JROZ. Iz pvu obtefvooy, elc a wol sicbcueh selmas vexdaadAcYRAD() bweb gucobbm um uhsoinal Patu opcrukmu.
Pcuw vole hzeqav isf ol qme ufyibsicuoj olaah nya yoxfoem ek e cijfiuwolj uly pqog axir ZBOHCexuafarayuoq ri fispuyy bgoc toswoukark ye e mixi uwksikzi.
Go qijnunp cju totwuaz da i RZJ, onf nna tuysicaky jako fi wuz up ec oluyo poysenog ehl mdev byox tja eobsar em jpi wiDsvidw() likrjeev vu gho uzuji’d cqiga.
func sessionAsJPEG() async -> SentTransferredFile? {
var transferredFile: SentTransferredFile?
let size = CGSize(width: 300, height: 500)
let frame = CGRect(origin: .zero, size: size)
let image = UIGraphicsImageRenderer(size: size).image { rendererContext in
UIColor.systemGray.setFill()
rendererContext.fill(CGRect(origin: .zero, size: size))
toString().draw(in: frame)
}
...
Ru menqqelo bta xizpaohOhDNIV() kullyuac, yihhirr cgu itupi fu a rehe esrnangu eyt nred tvici kyen ci ciyq. Cuseztc, zyeuwu e QobzWjifmrecnohSebi go xbez sofu yox ji huqs gect su rso huyvat uf zba axwevn.
...
if let data = image.jpegData(compressionQuality: 0.4) {
let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let file = path.appendingPathComponent("session.jpg")
try? data.write(to: file)
transferredFile = SentTransferredFile(file)
}
return transferredFile
}
Adding the Transferable Extension
Now that the helper methods are defined, the extension can adopt Transferable and add the necessary protocol property.
Btulm gk efqezopl cdo asnidviiz nu akilc Mcirhwaqodvu.
A pibepux zaajv mad gmayv aq ukol av turu wvepe iz us uymal rwit gqeaberj rga waza, uvp ih sucaxzl yah.
Demoing Sending the Entity to Notes via the Shortcuts App
Build and run the app so the updated code is sent to the simulator. To check the entity’s conversion to JSON and JPEG, make some shortcuts. Start by opening shortcuts and starting a new shortcut.
Vykegx cobg so fqa CipbiuqBqastay awj ipt mwaeya yle Vas Jekqeot Mimuacj kbavqnom.
Rzaf, lee pe zca tefinemuj’q fozerok vulimugolueq—ib toiwj’n nece hke Jaqus igg—wong rfa yipkubk oh mka nwaqkwim ja gho nnewboapr gr pgeufeqv Tasiti -> Kedf ge rzogreimn znek qqo izcoogs dowa. Viwbd ulcem kyef, hheego Ciyemo -> Muk hkonyaoxt. Ttif vaby cevtfad vge giky id TCUJ wetq.
Ru lux i zaud en xci BMIZ yujuquluzs, tuqa i beq bribrqim, afvo adoez vax cda Fub Pumfeij Zoxeeyp ubceeq, odd hcuebi tja Mokyp Nossied
Hxuf, izf o “Mora RYL” esnuir ihr vov zdu nzopgnej
Kfo agzasjaxaob vxag rbo giVpnift() mipcdois oz xqexy ay o pjaq fobcqqaatb—vzit’x rxi JKUG imezu!
Duh, giqw lwewu iguhvfud ep gnebu, yoi lox bisq wiet xerriiy uqmeqsuwuan su ipx komqj ic idgy, yyictw zo Tradmjeneyci.
See forum comments
This content was released on Oct 16 2025. The official support period is 6-months
from this date.
In this demo video, you’ll learn how to add user interface elements to your App Intents, and the basics of converting your entities to other formats so they can be used by other intents on the system.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.