Switching to File Sharing enabled false - ios

I have an app already released to the store and I do not want to have my Documents folder visible to the end user in iTunes. Is there any potential issues from switching the Bool from true in the app store version to false for an update?
All existing apps won't see have any issues? I tried googling and couldn't see any mention of this causing a problem but just wondering if there's anything I need to worry about

I've made the experience that that's not a problem. Users of the old version still see the Documents folder of the app in iTunes, while users who update do not see the folder anymore.
Also, nothing changes to the files in the Documents folder. Files that are located there remain there, no matter if they were created by the app or if they were copied by the user via iTunes.

Related

Create a file through a Cordova/Phonegap app that can be opened by another app (ios)?

I'm able to create and save files using cordova-plugin-file, and have been saving and accessing them from within the app to cordova.file.documentsDirectory.
The problem it seems is that all the directories that one can save to are private, Cordova-plugin-file documentation
I would like to be able to have these files saved in (or moved to) the ios blue "files" folder, so that they can be opened by other apps such as Numbers, Pages, etc. It seems so simple there has to be a way to do this, but I can't find it after more than a few evenings of searching and trying different ways.
I'd be grateful if someone could point me in the right direction.
From what I can tell you can save to the documents directory "cordova.file.documentsDirectory". By default this directory is shared with iCloud, so a file saved here could be opened through the ios File folder and a user could then select the files and hit the share icon to open with the appropriate app, such as Numbers etc.
In order to turn on iCloud you have to pay the developer fee to Apple and select the options to do so. I found the article "Working with the Files App in iOS 11" to be helpful in starting this process.
I don't have the paid developer account yet, but from what I'm reading it should work once I activate one. I'm open to a better solution or critique.

How do I properly enable iCloud document sync for iOS app?

In my cordova iOS app, users can back up their data to a file which is saved in the Documents folder within the app's container, which then should be synced to iCloud. However, though the file is saved it is never synced to iCloud, so clearly I must be missing something. These are the steps I have taken:
iCloud container registered on developer.apple.com and iCloud Documents capability enabled in xcode:
NSUbiquitousContainers dictionary added to Info.plist:
Archive build created and uploaded to App Store, build released to testers via Test Flight (Note: app has already gone through review process and been released to App Store).
Note, Cordova config.xml does not contain BackupWebStorage setting so cloud backup should be enabled (not sure exactly whether this affects document sync).
User saves backup file, which is saved to app's Documents folder (Note: the app uses the cordova-plugin-file plugin to save the file to the location denoted by the plugin variable cordova.file.documentsDirectory):
At this point I would have expected to see xBrowserSync appear in Storage & iCloud usage settings, but I do not:
And neither do I see an xBrowserSync folder appear in the iCloud Drive app:
And of course I never see the files synced to my Mac or on icloud.com.
Clearly I'm missing something but I can't see what. I've read many SO posts regarding getting this working and I find Apple's documentation unclear and confusing so I'm kind of stuck at this point. Could someone please point me in the right direction?
After some further reading I believe I know what's missing here. I hadn't realised you need to explicitly tell iOS to upload a file to iCloud Document Storage, which is what will allow files to appear in iCloud Drive on the user's devices.
So, I need to write some (iOS) code that utilise the FileManager class to:
Call the url(forUbiquityContainerIdentifier:) method in order to get the location of the local iCloud container and initialise it (at which point the app will appear in Storage & iCloud usage settings)
Tell iOS to upload the file to iCloud by calling setUbiquitous(_:itemAt:destinationURL:)
I'm building a very basic Cordova plugin to do this. I'll update this answer with a link when I'm finished.
Edit:
The cordova plugin I developed is called cordova-plugin-icloud-document-storage. It currently only implements uploading documents to iCloud (i.e. setUbiquitous), it doesn't implement the other iCloud functionality of the FileManager class (such as managing cloud updates or version conflicts). If anyone would like to develop this functionality please do submit a pull request.

Fetching previous saved database file after reinstalling the app

I am new to ios development so please pardon if I am asking a silly question.
I need to check if my sql file from the previous installation of the same app exists in the device directory already. If yes, then I need to fetch that file instead of making the new one. But the bundle folder of the app changes after reinstalling the app. So I cant guess the name of the previously installed app bundle folder. I tried to save it elsewhere on the device, but it isn't allowing me. Please suggest me the solution.
What you're asking for isn't possible. If an app is removed, all its files are deleted as well. In iOS, there is no app-neutral place to store files. When an app is merely updated, the update happens "in place" from the perspective of the app, and all previous files are available.
If you want files to survive a delete-reinstall cycle, you'll have to use a cloud service, such as iCloud, Dropbox or Google Drive.
once app is deleted. Application bundle and document directory and all files (including SQLite file)are deleted. u have to fetch all data from API.
In iOS each application is a Sandbox. This Sandbox consists of Application bundle and Mutable part where you store your database and other files which are mutated during the life span of an application.
When you delete the application, entire Sandbox is removed. The only thing which does not get remove is the data which you have stored in keychain.
When you update the application, only application bundle gets updated and Mutable part remain un-touched. So while re-installing the application when it is already present (technically updating the existing application on the device), you can find the same file from the same location.
You can do one thing you can take daily backup of that file on remote server and when you reinstall app check that file exist on server if exists than download else create new.

Is there a way to not erase the documents directory when uninstalling the app?

I'm developing an AIR app for iPad, and I found that when I uninstall the app, the documents directory data gets erased, is there a way to keep this data even when I delete the app or this behavior is regulated by iOS and there is nothing I can do about it?.
Thanks.
No you cant
From The iOS Environment
For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.
So you delete the application all the content regarding that particular app gets deleted.
as soon app get uninstalled the document directory folder also get deleted with that. Although you will not able to access that folder from other apps so there is no need to keep that.

Do app updates overwrite the app's home directory?

I use the NSHomeDirectory() function to get the app's home folder, and write to the Documents directory within that. I'm curious, though, what happens when the user downloads an update for the app from the App Store? Will it all be deleted? When I delete the app on the device, then reinstall it, it's wiped out. So, I'm curious to know what will happen with an update. I can't find this in the documentation at all.
Stuff inside ~/Documents/ and the user preferences are preserved during update.
See the iOS File System Programming Guide.

Resources