|
At the moment, In my app, I store json files and images as data in the local device's storage, using the document directory. Is this document directory unique to the app (has each app it's own documents directory?) I assume yes. What I want is that the app saves usage data to the user's personal iCloud somehow and that same data is shared between the user's different devices (ipad, iphone). But i don't want them to be able to access these files directly on iCloud, so somewhere obscured for the user. Any nudges in the right direction, what do I need to make this work ? |
|
|
|
SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
Correct. You can store data private to each user or general for all your users. It's essentially an iCloud-based database in which you can store records and assets (like image files). If you haven't already, and I assume you haven't, check out Project33. |
|
|
|
Images would be stored in CloudKit as |
|
What about storing it in iCloud Drive in non-public directory? I think that will be much easier |
|
|
|
I just did this some days ago for my app but with public folder that is visible. But it wasnt visible until I appended "Documents" directory to the path and yet the file writing still worked.. So I guess you can get reference for the container and it should make the files hidden :D I am actually planning to write a blog post about iCloud Drive so I think I can move it forward to today if you were to have problems with finding materials about it |
|
@nemecek-filip No need to rush it forward to today, but I am really curious how to read and write json and images to iCloud drive directly (no database like environment) to my own apps folder. When you have your post ready just let me know. Thanks in advance (I really can't find anything on this on the web) |
|
@Gakkienl here you go :-) https://dev.to/nemecek_f/ios-saving-files-into-user-s-icloud-drive-using-filemanager-4kpm I went by pull request on GitHub so I hope I did not forget any important steps. Now saving to iCloud Drive looks pretty easy but when I was looking into it the first time it was super intimidating. I haven't had the time to delve into the hidden folders. Let me know if you discover something! |
|
If you are using SwiftUI. you might want to look at Coredata and CloudKit. This is a good video |
|
For some reason I now have to try all this out! I don't need it at the moment, but i suspect it's a something that can come up in app development quite easily :) |
|
|
|
I got it working, BUT ... the icloud folder has a local sort of staging folder on each device from where it gets synced to the cloud. This could take a while, isn't always instantaneous. This folder seems to be well hidden, just browsing my iCloud drive I couldn't find it. Searching for my projects.json helped me locate the folder. Now the real caveat, My iPhone reads and writes to this folder and the app is working fine. If I open my app on my iPad it doesn't read the projects.json from the cloud drive it seems, just from the local staging area. Also the projects.json doesn't get overwritten. After a while a have projects.json, projects 2.json, projects3. json and so on. The app should always overwrite the file. Also on iPad, when the local file is synced (and becomes say projects 2.json in the cloud), I no longer have projects in my app, shows an empty screen .... Seems I need to let go of the iCloud functionailty for now, doesn't work as I expected. More info on the matter is really welcome| |
SPONSORED AppSweep by Guardsquare helps developers automate the mobile app security testing process with fast, free scans. By using AppSweep’s actionable recommendations, developers can improve the security posture of their apps in accordance with security standards like OWASP.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.