nspersistentCloudkitContainer, похоже, не обрабатывает удаленных изменений в режиме реального времени для обновления интерфейса Swiftui. Контейнер = nsperSistentCloudkitContainer (имя: "BulfboardModel")
let description = container.persistentStoredescriptions.first! Nsnumber, forkey: nspersistentstoreremotechangenotificationpostoptionkey) < /p>
let containeroptions = nspersistentcloudkitcontaineroptions (containeridentifier: "icloud.com.evan.awesomecopy")
containeroptions.databasecope =. /> description.cloudkitcontainerOptions = containeroptions < /p>
// Просмотр контекстной конфигурации
концентра Изменения в базе данных < /li>
[*] Включено молчаливые уведомления (woodsendContentAvailable = true) < /li>
not used-visible оповещения (shupbadge = false, alertbody = nil) < /li>
подписка: "awesomecopy-databaseChans" < /li>
< /prete ud>
Func Application (_ Приложение: UIAPPLICATION, DidReceivereMotenotification userInfo: [AnyHashable: any], fetchComplotionHandler
opplionHandler: @escaping (uibacgroundfetchresult) -> void) {< /p>
if isCloudKitNotification(userInfo) {
// Access container to trigger processing
let container = CoreDataStack.shared.persistentContainer
// Force view context refresh
DispatchQueue.main.async {
container.viewContext.refreshAllObjects()
ClipboardManager.shared.loadClipboardItems() // Reload UI data
}
completionHandler(.newData)
}
< /code>
} < /p>
Обнаружение уведомлений CloudKit < /p>
Комплексная логическая проверка для Cloudkit-специфических ключей: < /p>
- userInfo ["ck"] (изменение токена) < /li>
/> userInfo ["cloudkit"] < /li>
Клавиши основных данных Cloudkit (nspersistenthistorytracking, ckdatabasasubscription) < /li>
Silent Unfification Catterns (vailable = 1 без пользовательского контента) < /li>
< /ul>
< /ul>
.refreshable {
await bubboardmanager.shared.forcecloudkitsync ()
} < /p>
где forcecloudkitsync () reinitialize the NesserSistentCloudContainer для принудительного подключения. Works
CloudKit sync between devices (data eventually appears) - Remote notifications are received and logged
- Manual app restart shows new data
- Local changes sync to other devices correctly
- Pull-to-refresh doesn't show remote changes
- UI doesn't update when remote notifications arrive
- Need full app restart to see changes from other devices
[*]iOS 17+ Target
[*] Swiftui с @fetchrequest
[*] nspersistentCloudkitcontainer с базой данных CloudKit
CKDataBasasubSupprupt>
Подробнее здесь: https://stackoverflow.com/questions/797 ... -is-locked
Мобильная версия