Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Background sync not triggered #25

Closed
evanrobertson opened this issue Oct 16, 2017 · 11 comments
Closed

Background sync not triggered #25

evanrobertson opened this issue Oct 16, 2017 · 11 comments

Comments

@evanrobertson
Copy link

evanrobertson commented Oct 16, 2017

I'm currently trying to get this set up to allow me to sync an array between devices.

In my AppDelegate I add

Zephyr.debugEnabled = true
Zephyr.addKeysToBeMonitored(keys: "defaultToSync")
Zephyr.sync(keys: "defaultToSync")

Which when launching the second device will pull in what value has been set.

I then change the value using:

UserDefaults().set(value, forKey: "defaultToSync")
Zephyr.sync(keys: "defaultToSync")

My second device never seems to pick up that things have changed, the device making the change does say it has synced TO iCloud.

My understanding is that the key being monitored should at some point see the change?

Any help is appreciated.

@ArtSabintsev
Copy link
Owner

Thanks for the report. I'll take a look today.

From experience, I know it's not instantaneous - when/how-often to sync is under Apple's control. Mind doing a test in which you wait 30-60 seconds between checking devices, or have you done that already?

@evanrobertson
Copy link
Author

evanrobertson commented Oct 16, 2017

I gave it ~15 minutes just sitting and waiting on both devices. That is; getting them both to a point they had monitoring set up, then changing the defaults on device A, see the TO iCloud call, then waiting for device B to see some sort of change/log.

Device B will pull in the change if I call sync on it, however I thought the background monitoring would take care of that. The stuff I am syncing isn't time critical, I would just like it to be triggered within a decent period (~30 mins) otherwise I may need to find an alternative.

@ArtSabintsev
Copy link
Owner

Thanks for specific testing. I'll take a look in the next 24 hours and perform my own tests as well.

Thanks for your patience, and my apologies!

@ArtSabintsev
Copy link
Owner

ArtSabintsev commented Oct 17, 2017

Just curious: Do you have Key-Value Storage enabled in the Capabilities tab per the instructions? https://github.com/ArtSabintsev/Zephyr#setup

@evanrobertson
Copy link
Author

I do. I assume the fact when I trigger a sync on a new device it gets the data down means that part is all working correctly?

@ArtSabintsev
Copy link
Owner

Yes, correct. Just making sure. Wanted to eliminate non-code-related issues before diving in. Thanks for the clarification!

@ArtSabintsev
Copy link
Owner

One more question. When you say device, you mean physical device, not simulator, correct?

@ArtSabintsev
Copy link
Owner

Alright, testing on to devices, doing an explicit sync does work (e.g., calling sync() explicitly). So, that pretty much narrows down the issue to one function.

https://github.com/ArtSabintsev/Zephyr/blob/master/Sources/Zephyr.swift#L369-L384

@evanrobertson
Copy link
Author

So I was using the sim to set the value and a device for the update. Would the sim update not trigger an update on device when set? Even though it does get to the cloud.

@ArtSabintsev
Copy link
Owner

Nope, it wouldn't. It has to be on 2 physical devices. Anyway, I found the bug. Will push a fix in a moment.

@ArtSabintsev
Copy link
Owner

Fixed here: https://github.com/ArtSabintsev/Zephyr/releases/tag/3.0.1

Feel free to follow up if you're still having issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants