Hi, I have designed an app which needs to reschedule notifications according to the user's calendar at midnight. The function has been implemented successfully via backgroundtask. But since the app has enabled iCloud sync, some users will edit their calendar on their iPad and expect that the notifications will be sent promptly to them on iPhone without launching the app on their iPhone. But the problem is that if they haven't launched the app on their iPhone, iCloud sync won't happen. The notifications on their iPhone haven't been updated and will be sent wrongly. How can I design some codes to let iCloud sync across the devices without launching the app at midnight and then reschedule notifications?
Thanks for sharing. SwiftData + CloudKit is based on NSPersistentCloudKitContainer
as of today, which doesn't do any synchronization if the app is not launched.
Even if the app is running, it will be up to the system to decide when to synchronize data. There is no way for an app to force NSPersistentCloudKitContainer
to synchronize with CloudKit.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.