Open jessegrosjean opened 2 months ago
Update It just started to work (so I see updates on my MacBook without having to put app into background and bring it forward). I didn't change anything that I can think of. It would be nice to know why this behavior changed.
And like that... back to old behavior, but worse. Now the Mac app UI doesn't update even when I put it into the background and bring it forward. I need to quit and reopen the Mac app to see changes. All the while the changes from Mac to iPhone are showing up instantly.
So summary in my testing (with no code or config changes) is:
This feels like a macOS bug somewhere... not a throttling of CloudKit. I say this because even when macOS version hasn't reflected changes from the iOS version... it can still instantly send its own changes.
For example right now the Mac version is being problematic... and not showing items that I've just created in my iOS version (unless I restart app). But even in this state if I create a new item (or delete existing) then that change is instantly shown on iOS version of app. It's just changes from iOS that are not showing on Mac.
Help me understand and fix! :)
Just a wild guess: Does it behave differently when you launch your app from Xcode vs. from Finder? Or do you see any differences between the CloudKit development environment vs. the production environment (see the docs here)?
@marcomasser Thanks for the idea, but I still see the same behavior in production environment.
Here’s a video of exactly what I’m seeing: https://vimeo.com/957328976?share=copy
Here’s code I’m using: https://github.com/jessegrosjean/sample-cloudkit-sync-engine
Hi Jesse, when switching to production are you also changing your aps-environment
and com.apple.developer.aps-environment
entitlements to production
? These entitlements are important for the push notifications CloudKit receives when changes occur on one device.
I would check that the macOS device is correctly able to receive push notifications. On the macOS device you can listen to the NSApplicationDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:)
callback to confirm you're getting correctly registered and receiving a device token.
I am then testing sync by running this app in my MacBook and my iPhone. Generally sync is working, but the behavior is very different when syncing changes from macOS -> iOS compared to from iOS -> macOS:
Is this known/expected behavior? Any way to fix?
I have also tried calling
try await self.database.syncEngine.fetchChanges(.init(scope: .all))
on the mac, but that doesn't seem to help. I must command-tab to another app, and then command tab back to the SyncEngine app to see changes updated in the Mac UI