I have two collections set up in my Firestore database:
let COLLECTION_POSTS = Firestore.firestore().collection("posts")
let COLLECTION_USERS = Firestore.firestore().collection("users")
In COLLECTION_POSTS, users' social posts (e.g. Facebook-style post) will be saved. It can have pictures, so I would not want to let these posts be cached locally. However, I would allow data from COLLECTION_USERS be cached. It does not take up much space in hard drive anyway.
So I wrote a code like this in AppDelegate.swift:
let settings = FirestoreSettings()
settings.isPersistenceEnabled = false
COLLECTION_POSTS.firestore.settings = settings
But I am met with this error message:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL ASSERTION FAILED: Firestore instance has already been started and its settings can no longer be changed. You can only set settings before calling any other methods on a Firestore instance.'
Is there any way to selectively deny offline persistence for each collection in Firestore?