I'm writing an ios app and I managed to add it to "open with.." feature for any other types.My question is after I opened the file with my app how can handle it? I know it will be saved in Documents/Inbox folder in the app however my app will be dynamic and will extend in time.I need to access initially opened file's variables (like name, path etc).
My second question is, after I get the file I want to show ViewController1 rather than when the app normally started ViewController. Should I need to store the count of Documents/Inbox files or are there any other ways?
Related
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.
Background
I have a dictionary with more than 100 keys that I've stored in a property list that I can transfer/load/save to from one Xcode project to another.
Research
I've looked at several posts on StackOverflow but most of them seem to deal with loading a plist from the main bundle, copying it to the Documents directory and loading/saving it from there with no way of retrieving it to use in other projects.
TLDR
I want to be able to 'export' a plist created programmatically as a separate file I can use in other projects unrelated to the current one.
Update
Thanks to #NSNoob I've figured out that I can manually access the new plist from the Documents directory. Now the question is, how? Isn't iOS sandboxed without access to the filesystem unless it's jailbroken?
You can get Documents directory contents of your app like following:
Connect your device to your mac
Open your Xcode
Click on Window and select Devices
Click on your device
Search for your app in installed apps list
Click on your app
Click on gear icon
Click on Download Container.
Right Click on Saved xcappdata file.
Click on Show package contents.
That will open your documents directory and you will be able to find your modified plist there.
Having only worked with Android/web dev before I am having a hard time figuring out where in the world my file should be getting copied to in iOS. After reading the file browser documentation on the iOS developer resource page it says that each app is an "island" which contains its own folder system. If I want to have my user be able to copy a file from my app's sdk to their iOS device, where should I put it?
I downloaded a file browser app from the app store on my iOS testing device but am I right in thinking that there is no global file browsing system?
I am using a Cordova plugin called Asset2sd which works perfectly for me in Android, getting the root storage folder and downloading the file to there. It has no iOS alternative so I'm going to have to figure something else out, I just need to know where to start. Do I have to have the user access my app's internal files somehow? Can I create a folder for them to look in when they download my app? Some documentation or something would be wonderful. I am totally lost.
Thanks!
You're right. Apps don't have access to the global file system. Each app only has access to their own app directory. Here's in-depth information on Sandboxing: https://developer.apple.com/app-sandboxing/
In your app's sandbox, you basically can manage files as you want, i.e. download, copy, move, delete, etc. So you can create a folder Downloads in your apps documents directory and then display the contents of this folder for instance in a table view.
Related documentation/links:
https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html
https://stackoverflow.com/a/6907432/967327
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iPhoneAppProgrammingGuide.pdf
I would like to know if it is possible to let another iOS app open a file my app has created and then the other app edits and saves it just in the original location where my app had saved it at creation time. Or, instead, are files opened with the NSUrl in UIApplicationLaunchOptionsURLKey just read-only so they just can be saved in the other app sandbox?
You can't edit other apps sandbox, it's private to your own app (except for the Documents folder, that a user can access from iTunes).
You also don't have access to the file system of the phone.
Welcome to iOS :)
The best way to achieve this is a custom URL scheme. The other option would be iCloud, but I think the URL scheme is the way to go here.
Edit I see the link doesn't work correctly, not sure why, just scroll the page down to the Communicating with Other Apps paragraph.
I'm creating an app and when a person use this app, lot informations are recorded in a txt file;
If I want to make changes at this app, I must delete app from device. Then, how can I save the txt file before I delete the application?
Is there a way to do this?
Instead of deleting the app to make changes, install an updated app with the old app in place to preverve the content of the Documents folder (NSDocumentDirectory).
You could also save the data in the cloud whenever the app exits.