ios - Keeping Core Data in sync with multiple watches -
i'm writing iphone , watch app. i'm planning on supporting ability pair multiple watches phone.
the iphone , watch app both read , write core data datastore, , i'll use watchconnectivity keep them in sync (using transferuserinfo:). user write/dictate on 1 device, , appear on other.
i'm struggling figure out how support multiple watches. given following scenario:
- user using phone/watcha
- over course of day, user adds 10 items
- end of day, switch watchb
how watchb in sync phone/watcha?
- will wksession automatically replay
transferuserinfocalls made when watcha paired? - do need somehow keep track of watchb needs , replay myself?
- do send entire sqlite database using
transferfileapi (that seems bit much)?
will wksession automatically replay transferuserinfo calls made when watcha paired?
no won't. data gets transferred paired watch.
when switch other watch, you'd have arrange update store.
do need somehow keep track of watchb needs , replay myself?
in short, yes, if that's approach take.
one edge case if user replaces old/broken watch new/replacement watch, yet didn't unpair old one. wouldn't want keep track of growing number of changes watch won't ever paired again.
you'd have handle case user upgrades phone, , pairs existing watches new phone. device tracking , syncing should continue work across different device pair.
do send entire sqlite database using filetransfer api (that seems bit much)?
it depends on size of database, versus complexity of journaling , syncing data between 3 or more stores.
what new features me keep watch date?
if must maintain multiple stores, should take advantage of background refresh task feature in watchos 3 keep watch(es) up-to-date before user launches app, user won't have wait sync.
this answer might helpful, if aren't using complications.
what other options?
apple recommends design around different ways of interacting devices. user might want glance @ watch couple of seconds review items, rely on phone more complex tasks.
in case, maintain single store on iphone, , transfer needed data iphone displayed on watch. if changes, push updated data phone.
a "handoff" approach works best, phone , watch know recent items were, , user can switch between phone , watch during day.
of course, contingent on whether watch must operate independently or not while out-of-range of phone.
Comments
Post a Comment