caiyue1993 / IceCream

Sync Realm Database with CloudKit
MIT License
1.94k stars 245 forks source link

Pull inside a SwiftUI widget: does it work for you? #237

Open kleber-maia opened 3 years ago

kleber-maia commented 3 years ago

My app has a couple of Today Widget extensions in which I’m successfully invoking mySyncEngine.pull() method, resulting in an awesome user experience, since any remote updates are immediately available for the user.

I’m now working on a new version of such widgets using SwiftUI. I’ve tried a similar approach inside my provider’s getTimeline() and/or getSnapshot() methods, however it doesn’t seem to have any effect: no updates are ever pulled. The widget’s entitlements look the same as the old widgets. The debugger doesn’t show any error messages: but I’m not sure I should trust on that lack of output.

The only good news so far is that, when “Background App Refresh” is enabled on the device, remote updates received via silent push notifications will indeed update my local database and the widget will also reflect such updates on its next snapshot. But relying on that setting alone is not good news for me, since many users disable it and it’s also not available on macOS (while my app has a Mac Catalyst version).

Has anyone been able to pull this feat (pun intended)? 😅 Any tips or suggestions are much appreciated.