How to force iCloud file to be synchronized? - ios

I'm using iCloud drive to synchronize each devices of a user and it works relatively well except sometime when a file is not direclty uploaded to iCloud Drive. To unlock this situation, I have to open the "Files" folder on the device which send the file and it looks as it force synchronization because then all the other devices detect the change and it works.
A simple solution is to find how to force iCloud files synchronization ?
I didn't find any clean solutions, may someone have found a hack to ask iCloud to synchronize files ?
Thank's a lot

Related

iCloud Documents syncing, but can't be opened on other devices

I have a document based iCloud app that is giving me grief. Things used to work on iOS 7, but now they don't. I think it dates back to iOS 8.0 upgrade. Here's the problem:
In my app I create a UIDocument in iCloudURL/subDir and everything works fine on that device (call it DeviceA). I can close the app, start it again and read the file. Great! So I break out my second test device (DeviceB) and my directory query finds the all files I created on DeviceA. However, when I try to open them I get 'NSCocoaErrorDomain Code=260' which basically means "no such file or directory". Similarly, if I create files on DeviceB I can't open them DeviceA.
Another point of interest is that if I check "Setting->iCloud->Storage-Manage Storage -> AppName", the files are listed on BOTH devices regardless of where they were created.
So obviously I have some kind of iCloud sync problem, but I don't understand what's going on at all. Since iCloud seems to know the files exist, why aren't they syncing properly? Any ideas would be appreciated!
I can add code if that would help, but right now I'm not even sure what to show since most of it works as long as I stay on one device.
Cheers
I was calling
[UIDocument openWithCompletionHandler:^(BOOL success)]
multiple times on the same document before any one of them completed.

Store files permanently in iOS device

I need to store files(text/pdf) to the device memory permanently. If I write to documents directory, my files get erased once my app is uninstalled. So I need an isolated directory, like the gallery. Can somebody help me with this?
Since Apps live in Sandboxes you can not store files outside the AppĀ“s Sandbox. You could use iCloud or another Backup System and from there the user could restore the files when the App was deleted.
As far as I know, you can't, and that is for a good reason. There would be no way for the user to control how much memory you are using, nor a way for them to free that memory. Your documents should be removed when the app is removed. If you need persistent storage, store it yourself, on a remote server; don't try to pollute the user's device.
You should take a look at the UIDocumentInteractionController
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocumentInteractionController_class/
As far as I know this is the only way.

(iCloud) How to programmatically Backup/Restore data for all Apps like iTunes does?

I'd like to backup and restore files (or other type of informations like key-value, SQL-like transaction based info.) for NOT ONLY my app but also all the other Apps using iCloud.
I'm just new to iCloud and read only a few documents but it seems iCloud APIs are just for single App boundary (of course I understand there is an option for sharing information between 'Group' of applications).
What I want to do is backup and restore almost everything. How can I do that?
(There some apps doing this like
http://www.copytrans.net/copytranscontacts.php
http://www.macrumors.com/2012/05/18/elcomsofts-phone-forensics-software-offers-near-real-time-access-to-icloud-backups/)
I checked that the some of the Mobile App files are stored inside the "~/Library/Application\ Support/MobileSync/Backup" directory but there are only some of the files from all the files actually stored in iCloud.
And I tested CloudKit, but it just takes control over App's own data only.
Thanks in advance.
One thing to keep in mind when thinking about this is that iTunes actually doesn't backup or restore anything to/from iCloud. iOS device does it on its own: there's a daemon process running and if iCloud Backup is enabled, it will backup directly to iCloud, without talking to iTunes. Restore is also done without interaction with iTunes.
Next, as #rmaddy pointed out, your app on the device cannot access files of other apps, so you won't be able to do what you want from the device. If you want to do this via companion app running on PC/Mac then it might be possible, but will depend on what exactly do you need/want.
Re: contacts. Apps can access AddressBook and thus can sync/upload its contents. Apps can also access some other shared data, such as Photo Library. This is still a far cry from your original request to "Backup/Restore data for all Apps".
Re: downloading iCloud backups. Downloading isn't a big deal those days (Disclosure: I am the author of that forensic tool to download iCloud backups you're mentioned). There is even an open-source code for that. However, downloading and restoring are two very different processes. Specifically, you can download, but your app won't have enough permissions to write files in place.
Hope this helps and clears things up.

turn off iCloud backup for my application iOS sdk

I have some problems because of iCloud and i want to turn off its for my app,how can i do it in the code of my application,i thought about my problem and the decision can be turning off the iCloud, thanks for help
If you store files in Documents, they will be backed up to iCloud automatically. If you don't want that, the easiest way is to just store them somewhere else. Library/Caches is a good choice. If you really MUST store in Documents but you want to disable iCloud backup you can use the technique outlined here:
https://developer.apple.com/library/ios/#qa/qa1719/_index.html

Inspect iOS user's documents folder remotely

Recently a user of one of my apps reported that all her data was lost when she updated the app. I think this is a long shot, but is there anyway for me to inspect her 'documents' folder within the app on her iPad? Or a way for her to send me her document folder so I can see what's going on and hopefully salvage the data?
If she is a fairly technically capable user, you could have her use PhoneDisk http://www.macroplant.com/phonedisk/ to mount your app's sandbox and inspect the Documents folder.
If it is a jailbroken device you could ask her to download teamviewer, then ssh into the iPad.
Never tried it though! But that was an idea I got when I saw your question.
http://www.idownloadblog.com/2011/03/14/how-to-ssh-into-your-iphone/

Resources