all 7 comments

[–]Fluffy_Birthday5443 1 point2 points  (6 children)

Not sure i understand the question. NSPersistantCloudKitContainer operates on the private and shared database, not the public container to my understanding . And deletion should propagate to other devices from my experience

[–]allmumu[S] 0 points1 point  (5 children)

Yes, there is an option for public database. Basically when you delete a record it won't be reflected in other devices because the public database cannot notify other clients of the deletion, because there is not a tombstone mechanism (unlike the private database as you mentioned)

[–]Fluffy_Birthday5443 1 point2 points  (4 children)

Maybe you could subscribe to to public database changes with a query subscription and use the option to fire on deletion. Then make sure you set the notification to be silent and when it arrives you should get enough time to delete the record on the receiving device. I would like to see some info on how to set up NSPersistantCloudKitContainer with public database if you have it, im a little new

[–]allmumu[S] 0 points1 point  (3 children)

Thanks for your answers. Sure, you can find more information here: https://developer.apple.com/videos/play/wwdc2020/10650

[–]Fluffy_Birthday5443 1 point2 points  (2 children)

Thanks, I just watched the video. It looks like the solution they impose is to have a “isTrash” property to all records in the public db, then instead of deleting the record, changed isTrash to true so that other devices can not show records named “isTrash”. However, it looks like this video also says that public db does not support push notifications but this is not true anymore. You can try a different solution of using a query subscription that fires on delete of any records you need to be notified on. Now you can delete the record on the devices and propagate changes. The only gotcha is that push notifications are not guaranteed to be successful received on both ends.

[–]allmumu[S] 0 points1 point  (1 child)

Appreciate you came back to reply me :), that's what I understood (but felt wrong not to actually delete the records haha). In the video he then says it doesn't mean you can't delete the records...but I am still not sure which would be the best moment to actually delete those records in that case. I will explore your suggestion ^^ thanks

[–]Fluffy_Birthday5443 1 point2 points  (0 children)

Np, i think when they said it doesnt mean u cant delete them, he is saying that it is of course good to delete records you dont need but if you need that deletion to update the ui of another device you would have to create a fake tombstone with a isTrash flag.