I'm creating an app that allows the user to create a project, take photos and create labels in that project (using structs), then create a PDF later on. I've got to figure out how to save this data without connection, then backup it up to the server later. I want the app to be able to work both online and offline - whether the user has cell service or not. I've seen many apps where when you load them up, if you have no signal, you can select "Run Offline" or "Continue Offline."
How should I save the data locally until the user comes back into cellular signal and the data can be backed up to Firebase Firestore and Storage? I was considering using UserDefaults to save the data in a cache essentially, then whenever the phone is back within signal, the app automatically runs through this cache and backs everything up to the server. Is this the correct way to accomplish what I'm needing done? Is there a better way?
In the end, the data MUST be able to be saved whether connected to the internet or not - online or offline. I just need to figure out the best way to save the data until it can be uploaded to the server when back online. I want the data the user is creating to be safe in case something happened to the phone or to the app (maybe their phone shut off or there was a random app crash). By the way, the app is project based... so there's multiple files (projects) in other words. They may need to set up multiple files (projects) while offline and access one of them later on while still offline. It needs to put all of these offline projects in a container to be automatically backed up to the server upon returning to signal. These files (projects), with all the data in them, MUST be safe at all times until backed up - even if the user closes the app.
Please leave a detailed answer. I'm a beginner, as you can tell, and need specifics. If you reference a certain way of doing something, kindly leave a link to a tutorial or significant documentation, or explain it thoroughly.
Thanks!
Christian