Making iCloud documents local after iCloud is disabled by the user - ios

As noted by the Document-Based App Programming Guide, "When the user changes the preference, the application should move all document files in the application sandbox to iCloud or move all files in the other direction, depending on the nature of the change.”
But NSMetaDataQuery does not run when iCloud is disabled, so how can I get the URLs of the user's iCloud documents so I can transfer each to the local directory?

This was under the assumption the docs meant in the iCloud Drive switch. Instead they mean an option in the app's preferences that you add yourself.

Related

Storing a text file in iCloud in Xamarin

I need some clarification and Microsoft documentation is only confusing me more.
I want to save a txt file in iCloud so the user doesn't loose some data that belongs to them.
This db document is some information I am retrieving from a local database and storing in a text file. I have seen two ways of doing this.. however all the posts on this topic are very outdated and I don't know which way might be best or if they are even doing what I trying to do.
All I would like is to be able to have the user backup this particular file to their iCloud account, so they can still keep this info even if they change phones or delete the app and want to restore from iCloud.
Microsoft's documentation points me to this page https://learn.microsoft.com/en-us/xamarin/ios/data-cloud/introduction-to-icloud
I began setting up the provisioning profiles and setting the iCloud options on the entitlements page etc. However the documentation when sideways for me when they began creating a monkey page UI Document and having the user manager the ubiquity documents (which I don't want) I actually don't want the user even seeing this Txt file. However this option shows how to check if the iCloud is even turned on on this user's phone.
Now this other option I think is more straight forward and I read the documentation on it here https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/file-system using something like this to store and retrieve a document:
var libraryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "..", "Library");
However what if iCloud is turned off? Is this an automatic backup option?
Any type of explanation is helpful.
The iCloud storage API in iOS 5 allows applications to save user documents and application-specific data to a central location and access those items from all the user's devices.
About the definition of iCloud, you will know that it will save your data to cloud server. And it can be used in all the user's device if turn on the iCloud.
However what if iCloud is turned off?Is this an automatic backup option?
Therefore, if iCloud is turned off, you could backup the data in device although it will not be used for other user's devices. You could save it in Application directories. This should be a good chooice to backup your data. And you also can get the data when you need them.
In addition, you also can use other cloud server APIs to backup your data. Such as Azure Storage, Firebase Storage etc.

Can we import any file to our application from icloud?

I know users can upload documents to icloud from their applications. I want to access these documents from my application. Is it possible to access any documents in icloud from our application?
According to the official doc: "To locate documents in iCloud storage, your app must search using an NSMetadataQuery object". But I suspect you can't simply access the documents of other apps freely.

Can my app let users save some files to iCloud and rest on device

In Apple's Document Based App Development Guide, it emphasizes that our app should let users choose either to save all their files to iCloud or save all on local device. Is there reason for this? Can we actually allow users to pick some files to be saved on iCloud and some to be saved locally, like the TextEdit app on mac OS X? Will App Store disapprove iOS apps configured in this way if it is programmatically possible?
Thanks!
Here is a link
https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/ManageDocumentLifeCycle/ManageDocumentLifeCycle.html#//apple_ref/doc/uid/TP40011149-CH4-SW1
Setting the Preferred Storage Location for Document Files
All documents of an application are stored either in the local sandbox or in an iCloud container directory. A user should not be able to select individual documents for storage in iCloud.
When an application launches for the first time on a device, it should do the following:
If iCloud is not configured, ask users if they want to configure it (and, preferably, transfer them to Launch Settings if they want to configure iCloud).
If iCloud is configured but not enabled for the application, ask users if they want to enable iCloud—in other words, ask if they want all of their documents saved to iCloud. Store the response as a user preference.
Based on this preference, an application writes document files either to the local application sandbox or the iCloud container directory. (For details, see “Moving Documents to and from iCloud Storage.”) An application should expose a switch in the Settings application that enables users to move documents between local storage and iCloud storage.
If it makes sense for your app, there is no reason Apple would care if you save some files locally and some in iCloud. It's not a hard fast rule to be all one way or the other.

local core data store with icloud

I have a question regarding icloud store with core data store in iOS7. In the apple WWDC conference, it was mentioned that the core data store can be created in the sandbox and when the app starts receiving responses from icloud, the changes in the core data store will be merged into icloud store.
Now, (I might be wrong), but the conference further mentioned that the local core data store would be deleted once the app has switched over to the icloud store. So, my question is can a local core data store co-exist with the icloud store in iOS7 (so that the user has capability to work offline with data) ? And is there any sample code for this ?
In iOS 7, the Core Data framework takes care of managing the local store until the iCloud store is setup and available. This pattern also works for when the app is offline and it doesn't delete any data when the app goes offline (just double checked on my app in development).
The iCloud store will be deleted in another case. That's in the event the iCloud user account changes in which case the respective iCloud store file will be removed. In such case, there is a new API NSPersistentStoreCoordinatorStoresWillChangeNotification that allows you to store unsaved data before the store becomes unavailable. If the user logs in later with that same account, the data will be restored from iCloud (check the WWDC 2013 session 207 video at 15' for more on this).
As for sample code, there isn't any as of today. There is, though, iCloud sample code shared by AppleSpaceMan on the developer forum, which is what I used as a base and worked nicely.
You can work offline(no network connection) with the iCloud store as long as you have an iCloud account and are logged in to that account. I have just posted a sample application that includes the following features:
Use of Local or iCloud Core Data store
Includes a Settings Bundle (note that this creates a settings page in the Settings App) that includes:
Use iCloud preference setting (ON or OFF)
Make Backup preference setting (ON or OFF)
Display application Version and Build Number
Prompts the user about storage options when the Use iCloud preference is changed to ON
Migrates Core Data store to and from iCloud depending on the users preference setting and response to prompts
Detects deletion of iCloud store from another device and cleans up by creating a new empty iCloud store
Checks for existing iCloud files when migrating local store to iCloud and prompts user whether to merge or discard data in local store if an iCloud file exists
Makes a Backup of the Core Data store if Make Backup preference is set to ON.  Backup file name is persistentStore_Backup_yyyy_MM_dd_HH_mm_ss. To use it:
set Backup preference ON and next time the app is activated it will make a backup of the current Core Data store and reset the preference to OFF
file can be copied to PC or Mac from iTunes
to restore simply set app to use Local files (Use iCloud preference OFF) and replace the persistentStore file with the required backup file (note the file must be called persistentStore).
to then share restored file via iCloud again turn Use iCloud preference to ON and run App
http://ossh.com.au/design-and-technology/software-development/sample-library-style-ios-core-data-app-with-icloud-integration/

Best place for saving user data for Windows Store App

Disclaimer: I am new to Windows Store App development.
My app is a Windows Store App (for desktop). The app has to create some content using user's input and the data can be considered as documents. Also, the document'd be in a proprietary format. The user should be able to see all those documents listed inside the app every time he launches it.
My question is where to save these document files. I have no issue it is directly accessible to users without using app (it is their data).
The document suggest roaming (limited storage) and local storage. But both are deleted once the app is deleted (bad for the user).
http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
Document also states that accessing right for My Document folder is granted only if the developer is a company (bad for me).
http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx
Any other popular pattern from developers (apart from Azure, SkyDrive and any online storage)?
On app's first launch, you can allow the user to choose his/her folder as per choice, and then add that folder in future access list. So you can access that folder anytime. Please check below given links.
How can I save a StorageFile to use later?
Exploring WinRT: Storage.AccessCache
Windows.Storage.AccessCache Classes

Resources