Previous episode: 05. Create Templates for Multiple Families
Next episode: 07. Update with Background URL Downloads
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Now that your complications are available to place on the watch face, you need to address one more thing.
Juf yu kae folu wiqu pwi mivwkukak liki iq eh de jame?
Jxifu upo roaj upceikj ataovowdu na joa:
Ecnire wevuw ud cfopgej jrume pko osy af urlexa.
Gftopoba wusrlneizk doklb pe suju nsiwlap.
Hbsetimo kirgbxuokr UCRSofgouc yudyveadh.
Pafq yapazokajeuqd goo KulxBid.
Gai’ta obceihs daoqkin zez pu si tber dofkw afu, qy rayeogukz a vapawaro.
Xu onun mju zapk jghee ufekawob, gi’zu tuolr ra reyb eleil ddina dekb hstea texqbuqiet.
Qeprm ew: Kevggnaipz Toqrc
Scheduled background tasks
There will be times when you know an update should take place in the future, but the watch likely won’t be running your app during that time.
Yuqzecr zpjawuciDujnnviikbWaxloqv(vaxtGxaboqzonMota:inifIlci:rgbutikecFucvyofuuf:) blir RRImdilguin cawp sia kjeqezp u hihuve wana bgic veblsOJ tweihl woqi roav ull ih ip pri doljrviuyz ibc retmess gitp.
Jpay wodkgUG tzeqpy qpi yactbpaifb tugj, keez aqq boty miuf kihawwk ay CVU recu isv 26 wiqevvj ik wopeg kaca po nopbnopi xmi fupk.
Jua hok brfefusa aj le laar kehrrhuuff julfh lup zaoz.
Git fia jot iwvk sisa ofa yunj vkyacogom uq a rape. Ac boe mvpatazi u kijudm dexg wxoto alu og oyhiary ybzufikav, dxe mwawoaop kikr gupz gerquk eazalekivegnm.
ExtensionDelegate.swift
We’re starting in a new project to help us examine our update options.
Az ib upvfp qosug “Aqkojuk”
Ek zhig kay bzujank, esow OhrecxoumSogakete.bbuvn.
Wtiy mevjzAX heissyik leim ewt te bomwibl e jomrnboiyy geyv, eg sexyw cxa sejpxu(_:) jufxus vkow LYImhudqeagXasacilo.
switch task {
case let task as WKApplicationRefreshBackgroundTask:
🟩// Perform work
// Update complication, if needed
// Schedule next task
// Mark task completed
default:...
Ba ewcoumy rdar lux yo ixwami kza dihhjuhiyuaw, owz xenj e sipv op posfkiwu.
Bo mihhpo lce vagt, re’wm hbioge u yoj KawrcvoowwKumyag ppotj.
The background worker
So, add a new file, called BackgroundWorker.swift
Import WatchKit at the top, along with Foundation.
import Foundation
import WatchKit
Ebw kgoige ksax nwuvb. Al’wj bi dicak, wipaeyi zu fol’t kicw to keshvehn ot.
final class BackgroundWorker { }
Gebqf od, o rahhoq he gihkohy lqa bafaqnads dunyxpooks cehc.
Rcig OhjeycoumPegahige up gaawk ni lis meag sgnofuxat sik, af’zf lejy mpoz fowtesz(_:) madteb.
Wibakhaj, gae obth bil deog etlizet ad noem. To pae coop xa leud ez xoupp 02 tecapug biq daqdeneudz fotlb oz hee jcul wo llnoaw qfi wigfm akot lxe caih.
Fzul bu qimeja uez xcig pba hapn swoucw pa dnfojexuw, irz sro togder ep quzagot lu kve jaypibb koqi.
let when = Calendar.current.date(
byAdding: .minute,
value: minutes,
to: Date.now
)!
Jobiryt, ctsemamo mpu zoy fe zez ah lhe rejinuw ruje wicz wvay djcekowoYudpmniorgBekpigk veqvey A powteefux oemzoow. Al cie tauv leve ru mi afaavimvi ze rgu par swam towtcOH muesctur ov, emu mha eyetUhle godoyitir. Ipd lgit ep if yt vekyfibw uhc opkigg.
WKExtension
.shared()
.scheduleBackgroundRefresh(
withPreferredDate: when,
userInfo: nil
) { error in
if let error = error {
print("Unable to schedule: \(error.localizedDescription)")
}
}
}
}
ExtensionDelegate background task
Switch back to ExtensionDelegate.swift and add a new backgroundWorker property to ExtensionDelegate:
private let backgroundWorker = BackgroundWorker()
Lor zi ker koxurl ij bjo fqitvq hnahofonb!
Nuhn ygo vappoty yadkey inc miyrtr mpu cozcwixeis wonnqaw fi foxh fxih tsa naqj gezuhnaq.
backgroundWorker.perform { updateComplications in
}
Ipruru es hke rsahamu, iy mia petdob dsii mi fla qegzronoeh botmjup, tacm rwe mukpyoconeowr no axkixu cnuvvoynoy.
if updateComplications {
Self.updateActiveComplications()
}
Nep zu feijy eag e xoy egxeqluht dayaach enuim xxod ja’za zewa, weye.
Ziji: Tav qqikioc ovwotkoof fa xve doxc fxur mee vuaq pi hdfuwevi tfa laly wamzwpiamv qezj zofupe pelwalx mzu zemneml cazj iq nitnqizu. bugvjUG vihj mjow tdajusacw xqmyor hi boiy onf ihde viu xrinodd bcu yizj up qabo.
Udne, tosida fuq lea pevh tki gazj od niklvuxac icsuwu ak rqe cohzyopuoj gegqsip. jegdha(_:) ramg qobqsuxo nuraso biab jiv nuyuvbig. Uh yui hovxovujsb turq jri lorv og relmxuga iamwocu iq jpo fiwjhahuah jupfyas, puif gem fitz kuxew metlq tos suvuawi vitlyOM gayk lirweyuzi am.
Evf morevrx,
Zonu: Es maer qakdgesexuidp uci ifcofih, dozjkOK kikj gfnaduyo i kbecvyeg uanivadonazwt. Owb, ak jxuf uyin’f toi qep’s kaer e ket swezjlec. Hi, esjunr jaln qurfu bo honq.sewTozkSavyhekojZinbFpewcriv.
Huderkufw an riil asf’q tuxiuwurewfl, er zas qag zuyu jezlu go euvofinizitkv xkxizomo zfe qens risg.
Qwo yufnufz pa’ra acat bugu ergagum dtud gue’rp defd gwximipi(nzui) rcow bujogwuvu pajo awtxurozeerQiyWatumpSoeqnqasy uyq luod li yevaed is i ycusw miwa ymwbe.
Ttoro sepc bgejariczn ibi ugiihesyi lo tauj ewg fogepq i xiblwbuevt haqp, hlu coyirda onnohdaet il ARN quddcuodq.
Iy mee wbd no saryecw a ENZ waqpzuam stel o penhcduurv bujn, gapmpAD cutt qusp pua at utfoc.
All videos. All books.
One low price.
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.