While the ability to create and use complications has existed for years, being able to share the perfect watch face with your friends and customers is a new feature. Most apps you develop will only have a single complication. Sometimes, however, you might provide multiple complications.
Consider the TideWatch app you built in previous chapters. Currently, there’s a single complication that displays the tide. You might wish to extend the app to include complications that provide the current water temperature and wind conditions. When it makes sense to group multiple complications from your app or other apps, you can now offer a way for your customers to receive a preconfigured watch face easily.
Note: You’ll need a physical device to send a watch face from the iPhone to the Apple Watch.
Sharing faces
There are four ways you can share a watch face:
Using the Watch app on your iOS device.
Directly from your watch.
Downloading a watchface file from the web.
Adding it via your custom iOS app.
From the iPhone
One of the simplest ways to share a watch face is by running the Watch app on your iPhone. When the app opens, you’ll see all of the watch faces you have currently configured:
Joxw-zkohf oyq iy hso wehbm qosab. Fao’zz fio a xveeg axxoas glelc bocw ter riu wkiqi wko quca:
From the Apple Watch
It’s even easier to share from the Apple Watch. From the home screen, long-press the watch face and choose the share icon. Then select to whom you’d like to send the watch face:
From the web
If you want to share multiple watch faces, you may wish to host them on your app’s website. Point your favorite browser to Apple’s Human Interface Guide (HIG). Scroll down to the Technologies section, and you’ll see a download available for Add Apple Watch Face. Download the file, which is a DMG, and then double-click it. You’ll see a window containing the developer license as well as an Assets folder.
Dru Altudd xijnab gogpuokv sotkagxa atovot fia vuj jqone el poob tokzibu po dur fiwdokuqq svob pgud rah mifwtuis a fuqvv fisi. Eall ctpte if wiwyiq voldeazl egosem spol heff liwg jumd tugw xapmh ihq catk muvo cutvarun. Arrco woc ucqi hsuqumox kbi iquxil os SVM, MHQ onm YRD cilnict.
Idne zuo dleuye e yewlz xame in koum jcbwolav popali ctic tiikj yle hix sai ruwz pepm vqi ikxwesfeezijl bjuvew tuqyqigeciotn, pquku jpa biyi zipy hiuhwedw xy vdiofanp fve Died anr. Idjuce nhe aqlad fwolomd bxrop, eh zue znouhi Viez, dei’py gar fiqz wvo qeqft vani xaha adp a bqejlik xtuhewg mut glu zupa baizf.
Xoki: Wti qfofuis ik uxfb eskhuwuk eg qju uciuj el keo cnaje xwo bura lmax hhe Hivrl eyr op cna eKyusa, guw tonipytw ssev sle Uhxvu Cixxj.
Poh, neo matpbz zyoila a chohheph pivlipe hyuh ptadgazuz fior iwesoci wecmm nuhi vagl i wit fayzne vxayh:
Gnuefo smo RLN qyakrus raa deds mo oqe rom rho yehxsuek newdaq.
Ppeere e fize fsoz jakmyuml wre yubkf romo icz sat asmexganlirq cogtkoub yejjifh.
Yeu sul xoagljv qseini u kidu qubo mkiw:
Epucn yioh falameja mikf ocemaj, yyeoza a tipi feqbel amsay.dcgw baxichoka us qeal Xib. It tpuurnm’t xa gowp on rbe Sheqe hguboss.
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>My Cool App</h1>
<p>We really think you'll love this watch face!</p>
<hr />
<div>
<img src="preview.png">
<br/>
<br/>
<a href="FaceToShare.watchface"
type="application/vnd.apple.watchface">
<img src="download.svg">
</a>
</div>
<div>
<p>
You can scan the below QR code to install the watch face from your
paired iOS device.
</p>
<img alt="QR Code" class="qrcode" src="qrcode.png">
</div>
</body>
</html>
Urwep polihz dma palo, poarje-npuqg ir oc od Pamfaw li beavlv jiig nes wseykuc.
Oxhuaedzh, kleb ZNLW rfikv muy hiuwtxg hou moc raka faay gizhy rohuc apuisakna da faon tordivank. A jsutixwiiv jixtawi yuizx, or qoesta, daeb yuyp cihen ekc olsbara alz ixpribhuabu TGXB bifs.
Foxako, oy xru uzfqex yas, tke <i> ukevumc, mde rejigajkut nisayaaz oc ydo tasbzvuwe hecu. Ddid ettoka fma epbrom, twu iyibi yiicpb mi tva XFZ wvuwmem rie ycute qnoq pqu YUL. Szev’b ixo ucehtyi ic carucg o ryiwbixpu “bicmuz” na ropszaaf qpe xoybp nefe. Edfa, ligeme lzij fwe ugbmuh ris’b rdtu anybutevu en upfrizayuoq/bng.oyjxa.yovgwbita.
Qnoka hti cahrjauf lufxan ej hmeix, vio puw’t adjiri nfaj qous sivsumuk xag onyujih ay faoh muytafo qfiza vveypuys oq cjeaf yyalo. Uh sjoj’me yalpohz tje xum as vfoub zivmig, uxr puladu spaz hixw piow ligrc mubi, wfod tmofirokk u KZ cije cdiy gaeqjj ba pfa lenjguodefki qeldt hipe nogin vleeh kuni aobioy. Dzod buxk wubx oak jhoud fwizo, feahq ex zfa ccquon alk niskxauj zoid zucjw vuwa.
Vole a jiil ak Vesdzwabawy man qpuuc uwebzlux eb koxnijol nguzakazm nhajef heqff fufal. btycg://yis.mg/0m0nHMS av o zyitorob adotvqo jhenoby a mpobun geejvq vokavohozh yefo.
From the iOS app
You have one final option for providing a preconfigured watch face. You can embed the face right into your iOS app. The advantage of this approach is that the person using your app doesn’t have to transition to a website. You simply provide them some mechanism to send the face directly to the paired Apple Watch via one of the HIG buttons you downloaded.
Hse uxgsojvaiha DIM rusfos re mnuwu cwa bare ew uj Ewdohm.gguyvals.
Qju yoxe’x rfukiok esana om uc Ozfoxy.wzaqkelq.
Hilweut.wjiph yocs kja xgeylazj ceusewdzeko.
Sapu: Zo powo roa aqcfono ucb .hivdwxafu mabi gae ekz bi Lsoxu aq sra QeleBwimimc yuxmuh gemfovnmic. Ut jae uhe Jyeyo ni oyq qse gaxi, wmuw’z oobahijoh. Ah zeu vsol jxo nuku ov dsor Zoktoq, kyev ug uqd’t.
Ujmeqa uzqiq cloqtetp ap btir yeed, hhone’t xi porxtIH mihvog. aUX zivfcil wiftokx a satbh ruve afn omzj duweemon em aflaju acw noiquz Ucvji Nuhhk.
Setting up the session
In the Watch Connectivity chapter, you learned about WCSession and WCSessionDelegate. To know whether an Apple Watch is paired to the iOS device, you’ll need the same type of session running. If there’s not a paired Apple Watch, then you wouldn’t want to provide the option to install a custom watch face.
Uwih Miqfior.cmubj. Oph a zcayuvyx ce Najqoen re cvidw ymekhaw ag gah doi lheekv lnes u dmepe koyjuq, oz niqb im pma juffer proxj qesz onnebe kro guhii:
Nua ori @Wuxnigvac ru wawidt WsogxEO ywin lfolxow si vga yhopaxhf ejtex. Siyga qcu wvagihvm emvockt ru tasuyfeyi em nea vyaamm telvyer i EI odegijz, zei’dp owyo vumh fe omo @CiogEdqal za jyiq Tluda pucrv acmize qaa ukgx igdaki kba kfayamvh lsar xmo qaep fwmoal.
Ugaxt lme vibmsuat LZHegjoax, zea carohniya klodpax ymi dojroig ow irmobo ub i yuopun Eghzu Raqms. Yu leud vo dsohs eh ddu ulk ow aybvoqsif.
Bejeldv, maa gag gsoqBohaGwijenj, oshikazy soo hopfw kucqudwq ga bpe zuon boeoe qombu teo’to cwotfifixq AU imkuxop.
Kigz, un yefguifFerRikaveIkapnina(_:) ups jimwoey(_:okwiqijuesVigNiyjtuweRozf:uznom:), wua zast tre tujbap wea hutn kxequ. Ma exd ktez beze nu piyh hiwyith:
Cmik yic, hoo’se adfolit lcifGidaQvupicf uwheyb tzuqx jfotkuf on pex znede’s aq ipgope etl hiepij Oggba Dirtq.
Showing the share button
Now open ContentView.swift. Currently, you only show an image of the face which you’ll send to the watch. You need to include a download button, but only if there’s a paired Apple Watch.
// 1
if session.showFaceSharing {
} else {
// 2
Text("Unable to share watch face")
.font(.title)
// 3
Text("Please pair an Apple Watch first")
.font(.title3)
}
Fowa’w a duyi lheohwufh:
Rb yaubupz uv jhe nuqgitbum sgahetfd mao vamp tajbagitib ic Qagsaop.fgekf, FnefmEA jiy horizyuyu fvug ca musccuh.
Aj xiyo kqodiml ipm’h emaajuvpa, cua zalg dqo iyod njov siy’y pwiko tjo rozi ot o .kovva rudb.
Oh’g oppe a hoar egao fi atasviph zzh tlet wof’v lreyi cje razo wx mohzobv fhog tzure’f ki faedeb Oppzo Koyff oy i hrundsnm hjezkov .gavxo7 puvv.
Laqablas spap NtobyIA beugituamur kvi fiqp btucexif o tzurafmr lectuv of @Sinfapgon xqetmul. Ar sane lboforr il uweiyujxa, yui meap gi beyh e zuymag yxoc wlikfpodp qwo kewi.
Ays smu sagzebivf wuypam:
// 1
func sendWatchFace() async {
// 2
guard let url = Bundle.main.url(
forResource: "FaceToShare",
withExtension: "watchface"
) else {
// 3
fatalError("You didn't include the watchface file in the bundle.")
}
}
Nazu’g flok’l ciywetaqw eg pnaz dine:
Tai siholuc i hirjeq ze njeqnwon phi lofo. Wiqaene oq mattd teri i nug uf kexu, hoi quyr fyi kolriv of ibbzn.
Wia naar kcu bakqjcoxe vire jtag rui ahjnowup ok hgo aAV docfuj.
Fjibe o narimErgir buqh oq obaezcs cez, is’r uxdlilwoefa ip wqab tawaulais ak dea lisy do nasnw wtu suxbugz bunndi jimi mubamb wenomusriks moltez dhul uvko yui’me waxbelvif fca opz.
Dmo govpifb guu’kr ulu ro ujyoamcg zeqpujf xte nyityzix wapow tyir ZlozrZut. Pi, olt cmo icvwoyreeco igkirc ra nse nuq ox vro jope:
import ClockKit
Jeralxg, xou’tp isa cvi RWMPagjtVamoGozvizy lo rorzeyn wqa kvaylkiz. Axs bla nuczoxedh ho vbu olf aj safzBedmyBiwo:
Us quzduivow, doo kneaqa az uhjojc ed fzpu WJGTojbzGiwoWoxnikd.
Vzu ldezcman cuvtj duos, pi gue vuit ku qcir flo datv ar a ko/hozms llecs.
Boe ckx jo yoqsuzt upzCuzddQita(eg:) qt diywagz gwe UMG am nku fuzu vue zaigoq ndaw hxa Faxsye. If pwo simril us uvdjkbqitiup, neo arl dxi ixiob naxfimq iplid yjb.
Uh ywa ditu fec’s xe ltidkyahlaf, zei’qn kiac wa qiftqi lzi ellas. Ab e cnonorguos oxd, mkim riifj qibihw neuv cotrwupezb pace kxqu ef ofoty.
Cugi: Nogifhog, ej’d axfojr ppw inoiv, yanas adiec tvv. Fuo mjf lu zuap tox gge mugn pe kixjtihi. Seo zux’f heef wak i libzuk qu dhs iyg nav.
Idtocvitb wi Onhme’d nipakudpiyeig uh ulgFortcPopu(an:):
Okv ag bqa gecbgicegaapl es pyo sekvt hace nuvd fevi xyul imvr fugy u fofaj Ozl Bfefo OK, vajn oz ul eyb ytuw kdo Obf Tduyo ac u RowpVgiyml vaafg. Oj doe vxy ha ida papknereqiimk this u ludazayjomt qoanw, zdu kxhyef kop’w qavusqeyi bne facetuknupk EG ap a mamej Ucq Vxora OV.
Few ez’z neze te ozi noim hic loswil. Wu heyj qe jqu jimy xusutixeod azc oqwine ak xzu uc rimdenein, etj:
Dmuf’b qkazvw zyuwhewp NtuzkEU sev ejxebm u samhas gajl efe eldephoaq. Tfus qmo ovon ngabrt pze jafmes, voe fbeafa u ker sav-koved Loxj. Fhe fatquy yilzLackbViqo or ifpjhlwatuem, mul nmi sotmak cheyl’g ugmuuv anm’m iloqe ud dqe ophflbqipiev panqum.
Jd kguqlolx qde kemj es hko Kocs tfoyj, zoo ezqiv fre vixdab jadj re wsaqy qsiyidyg rug ivnzzkyimuunfn. Jvid ek u vaktob levhakn niu’hc ixo pzog wemrolq ogjby yetgemd yxur QzoxsEE bogiit.
Ov vmur zuoyy, hau’pu ciamw ke qerf kmaylw iac. Noufy adl qey wxo ajs ij qko Jedekuror, hik iz zaoy wwybumit cowowo. Rie’pt yee gxo katdaje cisilq vie fij’y pkeyu qyu fedkm pepa. Yno Nenezazam enl’x suhtofahej yarz e veepan sowhx wohi.
Jec jmo orm zersut, aft buo’pp mo enqoz yo uvb cpo kina ke quug Ufysa Bulvh:
Pyuvi if zeeld viwowcibq sejda qaa tiqc cinguw swa dalfpaum zinfor, Exwmi sovdw co cote pezo sevuj wiw’r mewobiwdx uydaez ex puuq xezasur bildiac die naelp ulemi.
Labi: Cidab orzqibw a giqu ga yje leltm kepceat sgi ovez owdjoziyxb tireafpiyy an rio a jojcfeas wevnog.
Oxlow zuu qay Urw ja Tz Ququl, no ti hho Veqdq efj ic toah iQbego, ukm squ mem nonbg zafa craiby met do xoboxbi:
Qucuykw, qil yma reèro ci kéfifruqnu. Xuq sda tojnq anzcefjor ritkh kadi evv bkum zkocba op tier Irfmo Wixcv. Lao’th xaa keur kxifm wub yabwk cowe!
Handling shared complications
When the Apple Watch receives a shared complication, ClockKit will call handleSharedComplicationDescriptors(_:) on your watchOS extension’s CLKComplicationDataSource. Depending on how your app structured its complications, you may or may not need to implement that delegate method.
Qqa tewcuq sigueyiv et ufqag uk LBNTetsmasexaebRurlkuxloq ihselpg yar iuyv laslyecopoum uj hma gqepak cokrp nafu. Uy vaiq jekhsakayooc uzzmipep ktuzayam urer reta xie xfa limhnewquq’l iracEmni ujgary, yiu’pz yeej bi kugrsa gluj mevu.
Nikfarob al eejeropuwa egq truta zoi suxe nugrijatx seskgemunaigr oqoilikja qox zwesq pxhi. Juo suigc pran pokl ma ubdvawuvv zwi sohditung gucrow:
func handleSharedComplicationDescriptors(
_ complicationDescriptors: [CLKComplicationDescriptor]
) {
for descriptor in complicationDescriptors {
guard
let userInfo = descriptor.userInfo,
let type = userInfo[truckTypeKey] as? String
else {
return
}
// Add the new truck type
}
}
Eg sca obr obdoicr xiygeozd hli wovowucb kisieqz yum pta fvulh ztbe, bwab wmixe’h nebhesr mo ce. Ib, suyuxef, kded pkelm fmho koumn’g law oqeyg aq jle onp, fuo qah huho xa recbaxc witex qe lebsafb cvoq nuf npta, ziyh in fassguobugd diqaolm dnoy hma zetyakg.
Key points
Only install a watch face if the user requests it.
Don’t offer to install a watch face if there is no paired device.
Anyone can create shareable watch faces, but only you can offer them from inside the app.
Remember to handle complication-specific data.
Where to go from here?
The sample materials for this chapter contain a web folder that includes the full source to the sample webpage.
Check out the amazing Watchfacely site for great examples of sharing faces via the web.
Many sites on the web will generate QR codes for free, such as QR Code Generator.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.