Closed cip123 closed 1 year ago
In the meantime, I added NSUbiquitousContainers to publish the files in the iCloud drive, but there is nothing there.
To test it, I turned on airplane mode, and the backup was still successful ...
Hi there!
First, in regards to writing files while airplane mode is enabled: This is expected behavior with iCloud. The ubiquity container is mounted locally on the device. When writing files to the container while airplane mode is enabled, the OS will sync the changes once the connection has been restored. The OS will not throw an error when doing so. If this is unwanted, you'll need to check for an internet connection before handing data to react-native-cloud-storage.
As for data not being persisted across re-installs: I can't reproduce this on my end right now. Are you using the latest release of react-native-cloud-storage (1.0.0)? Earlier releases are unstable.
In our apps, we only use CloudStorageScope.AppData
, so I can't verify right now whether or not this has to do with using the documents scope. Did you try switching to the app data scope instead? You might want to store a backup file in this scope anyway as files in the documents scope can easily be tampered with by the user.
If the problem is indeed the documents scope, I probably won't get around to checking this until next week. iCloud is a little peculiar with when and how iCloud files are stored persistently across reinstalls and when they're not.
You should be able to see files in both the documents and app data scope from a Mac by opening a terminal and going to ~/Library/Mobile Documents
. You should see the app container in there (as long as both your iOS device and your Mac have iCloud enabled and are logged into the same account). You're not able to view those hidden app containers using Finder, though.
Thanks for the tip; there is nothing for my app in that folder. Not sure if it has something to do with the fact that my app is still in development. I can find files for other apps, though.
I tried AppData,
and am getting Error: Directory for scope app_data not found
. Maybe a configuration error? Yes, I am trying version 1.0.1
This error is thrown when the OS can't find the URL for the ubiquity container. This usually happens when iCloud Drive isn't enabled or when you're completely logged out of iCloud. Are you testing on a simulator? What does CloudStorage.isCloudAvailable()
return?
Also, just making sure: You're not trying to use this in Expo Go, right? When using Expo, you'll need to build a custom development client (the development client needs to be rebuilt once you've added react-native-cloud-storage to your app.json).
isCloudAvailable
returns true. I am not using Expo Go, I created a development build. I also built and distributed via TestFlight and the result is the same.
Probably not related, but I noticed that for app data is checking the URL with a nil argument let ubiquityURL = fileManager.url(forUbiquityContainerIdentifier: nil)
.
I think the problem might come from the fact that my configuration is not react native and not really expo managed, the prebuild
stuff is somwhere in between.
I might have missed a step, re-running expo prebuild
after the configuration. I am going to give it another try and let you know.
Yeah, that was it. I didn't realize I must run expo prebuild
after each configuration change. I tested it with AppData
and it is working now. Thanks for your support.
Yeah, that was it. I didn't realize I must run
expo prebuild
after each configuration change. I tested it withAppData
and it is working now. Thanks for your support.
Great to hear.
This error is thrown when the OS can't find the URL for the ubiquity container. This usually happens when iCloud Drive isn't enabled or when you're completely logged out of iCloud. Are you testing on a simulator? What does
CloudStorage.isCloudAvailable()
return?Also, just making sure: You're not trying to use this in Expo Go, right? When using Expo, you'll need to build a custom development client (the development client needs to be rebuilt once you've added react-native-cloud-storage to your app.json).
Just curious - does this work on the Simulator, or not?
It does.
It does.
@cip123 I mean something like this: https://github.com/Kuatsu/react-native-cloud-storage/issues/29#issuecomment-1949884272 where you save it in one Simulator instance and then try to retrieve it in another Simulator instance?
First of all, thank you for the project. It is very well designed.
This is probably not a bug in the library itself, but I would like some guidance if possible.
I am trying to back up a JSON file and an image archive to iCloud.
I am using
expo prebuild
and I use the expo plugin:I also, to make sure, enabled the cloud container in the xCode project, but the result is the same.
For example, I am using this following code:
This uploads the file, and I can retrieve it afterward. But, once the application is deleted, it disappears. What's worse, I couldn't find a way to view these files to verify that they were uploaded to iCloud. Otherwise, it looks like they are just stored locally somewhere.
Do you have any guidance on how to solve this, please?