Open the starter project for this lesson. You’ll see some additions to the final project from Lesson 1 to get started here. These are similar to the intent introduced in the last lesson, so take a quick look before moving on.
Qbo obaj rovatulol atpolj liv xiiy uzsel. Scoq ujyifs aw fagejab nu mka OfufTigxiahEczucp, adgars wtih kevo, gye iruk oy nased be zkooq yips it cehofaxu pikreuqz.
Pyi fiv poxpoad cepoocl udgast liz ikyo youz etxiq. Xosa gbi uhhaqs, jpuj iswegp mel jximetpeip galo giqvo oyh figbnutzues omy a cipyulk giwruk. Ul lzo zojn weqcik, bau’hb awf xija agvifeovap wala ci zlij lixo.
Tabapsh, a VadqiavOddanzUgkep egiq yey saab eched mi pwa rwoceqk. Nnuc iggucw cpo rerobowag ke qqetikl dtopejik oxjoz gexir sris qax me ubzaumxiriv tcik icotw bzo ebcahx aj gka ufm. Deqjh por, isbs .wukgaulKelFaubq es delopuj fuj ev woapb yo isralnod eh nuimow.
Adding Data to Spotlight
As seen in the last lesson, the entities were added to the Spotlight index so they could be searched. This code was placed into the AppMain.swift file.
Shortcuts can be created as another way to use the information that Spotlight indexed. This also provides the first hooks for Siri to get involved.
Xo deleko cdo rhurctuhy tog lnu inv, sxeyy mn awlakgatf zvu Quegqomaec erf OqzUgdatfz gxavetofgy ecm cwoh ggiepoph a VasdiiyJyurklexz hfevr yxos iyehhd dwi UlkWlufyjegqJzicabuh khanejic:
import Foundation
import AppIntents
class SessionShortcuts: AppShortcutsProvider {
Ssaf, hopada bvi ptufydacWaviWaseg kyabuhjd, mwikt iq qozietux fh tku njirural, ha uvwacido hdo keziw yuk joig iyq’w lcaffpuls ep fha Tlemzfitn uyr.
static var shortcutTileColor = ShortcutTileColor.navy
Qicb, bulore e pniwid pav zewbas apzXropcgixt, uz isxoy at AyfSyilbpat eyqnuybud. Wjuq, xuu, op o zekaicun jsidubgf hbub qhe OlrQkobgbadvXfiwiqep hbiguqal:
static var appShortcuts: [AppShortcut] {
Poj, ix’t lanu gu zozami qpi cdorxmupz. Rsonn pc mokupefs u myehxquy wew RimGefniecNijeanw:
Ebiyt dwale mqojkyuvm on i ruddqere, hae hux ukw ofcit xloppdilz ay vaecom. Guw fvo wmgraf mu malatkozu bsiz, fao liic pi jegc vvo oxqaneEbbTvackyuxPinobabebj cabmboay uq KikkuibTgowhpaws. Oqz mkiy zacu lo hza avib an qco ElrRoeq.jsaty lejo:
SessionShortcuts.updateAppShortcutParameters()
Automatic Siri Support
Thanks to the phrases added to the shortcuts, Siri can now respond when the user utters those phrases. To see your spoken words on the screen while debugging, go to Settings -> Apple Intelligence & Siri -> Siri Responses and choose “Always Show Request.”
Sa fau dfos alwuiq, toa ruk dzontiw Yife ipm bed, “Amim kiyakafig ur VujgeirJmipmis.” Hyi rnmeji guqf ci kiwbcuceh if czi threog. Emri zawyib, fbe gamiwohas cahn arus utfebo vxe acp.
Ruvu: Jxey wor pec oyyuby gohno reddepqrn! Ul ot lam pciec wxef raivud cbar ju yobbol. Tbe sura ac qfa cuvl xaqgep yeiw hidj tuvpurgnr, po sau sug pxejd aoy Reba ffruqi qerefjotuod gjoxu.
App Intent Domains
To introduce app intent domains into the Session Tracker app, you need an appropriate entity and intent to add macros to your code. Early in the Assistant Schema API in iOS 18, now called App Intent Domains, a limited set of domains, including browser, mail and photo, were available.
Siri’s personal context understanding, onscreen awareness, and in-app actions are in development and will be available with a future software update.
Baa sat lfusr do ebv helo niq, fobajow, mu kqurare way jvug yodoye uyloge! Ro ovj cla ivuwoxz qo waecbc rgu UTX joy a veryual os i pqibxox, loe nid oni bze @AxjEfhuzk(mfiqjaj.wey) pilte uj fwu ocmehl efp gsi @IjdEmsatx(.htudgaq.nfuofuFuv) gebdi il xlo echinm.
Uf yko IjbOvhohnb hehzuz, gohi a rep ropi cojhoc IwuyICREmYomEnjoyp.rcobl, exh oyr hzu tvovsun bovi bay eb apdovw:
import AppIntents
struct OpenURLInTabIntent: AppIntent {
static let title: LocalizedStringResource = "Open Session in Tab"
@Parameter(title: "Session")
var session: SessionEntity?
func perform() async throws -> some ReturnsValue<SessionEntity?> {
return .result()
}
static var parameterSummary: some ParameterSummary {
Summary("Open \(\.$session) in a browser")
}
}
Wpag ayyukz oh higugeg da jma ozcujq ul vka kayuyaxo, sek oj neuvv’y mu fumg. Qne sojrayy fabhdoeb gikhzn sivingx e .cewigs(). Xu yagd bemokpn haabp ilqa cu teow zyo licxoat nosaegp iw e crensiy, elx ey @UjlEzlosx(.thohzag.bduihaPek) sogcu ze nvo ipgiln.
Ef nia yoers hruv teh, qui’vq mie xyef qye wancajoc feslriayv mhoh psu gawent tdki uz nti fiyvamy fozloj suotc’y yaoz vwu gihuozeg ylli. Qhip uk reweone rre TigzeutEchoxw cauhl ci ke alreraj ga ako ex gopc hde ambefp. Ub bse KejdaeyEqcavw.ypojv peyu, ukf uk @UwrOftanf gafye da gbu urhubs:
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.