Basically I want to know if apps work and store data independent of one another or if there is a possibility for one app to modify another. Also...
In what folder are apps and their data saved on a phone?
If I modify data locally in an app, will the data be saved in a public place where other apps have access or is it saved to a folder specific to that app?
iOS is kinda not that mature in inter-app communication.
Data can be shared between apps using the system clipboard and transmitted over the network through mediums such as email and webservices.
iOS devices also provide a straightforward and well defined method for apps to send messages and data via URLs and filetype handlers. These techniques diverge into two categories:
Custom URL prefixes, e.g. someapp://something/somethingelse?somestuff=whatever
Custom file type handlers by file extension (e.g. *.txt) or by MIME type (e.g. text/plain).
Custom URL prefixes are useful for when two apps have established a specific protocol, while custom file type handlers are much more general, and are designed in a way that allows any app to register itself and participate. This article describes the latter: custom file type handlers for chemical data. If you register your app for a certain filetype it will look like so -
Reg. your second part of question - If I modify data locally in an app, will the data be saved in a public place where other apps have access or is it saved to a folder specific to that app?
As such, each application is restricted in terms of where it can store data on the file system of the device. iOS achieves this by allowing applications to read and write only to their own Documents and tmp directories. Within these two directories the corresponding application can create files and also sub-directories to any required level of depth. This area constitutes the application’s sandbox and the application cannot create or modify files or directories outside of these directories. Check this
The general answer to the first part of this question is: "No". Apps are inherently sandboxed and thus can not communicate between each other. There are a number of exceptions to this:
If you have access to a custom URL scheme for the particular app (Facebook Single Sign On makes use of this).
Opening a document type that is handled by multiple apps on the system (like when opening an attachment in Mail)
If both apps are developed by the same publisher, there are options to use UIPasteboard, iCloud shared Key/Value Dictionaries (only small datasets though), or accessing a shared Keychain Store.
UIPasteboard has some odd behavior as you can have system-wide pasteboards or application specific pasteboards, and there's no guarantee when its going to be cleared or not.
The second question - folder structure - is variable dependent on OS version but generally all applications are stored under the /var directory, followed by a subdirectory structure that utilizes UUIDs to denote the application and then the main app bundle, with the standard app bundle structure (including the Documents directory).
As for modifying data and storage, once again, generally "No". Some apps will utilize UIPasteboard for temporary data storage, but generally you won't know about that inside another application unless you've written the original app.
Generally speaking every app has only access to its own working directory and saves all it's data there. So no app does have access to the data of another.
Except a few of Apple's apps like Photos, Address Book, Calendar and so on. App's can use a well defined API to get access to them and do some (controlled) changes. In future iOS versions (beginning with iOS 6) the user will then be asked if a third party application should have access to the data of these few Apple apps.
There's no file-based solution from Apple directly to share data between apps yet (except the clipboard, which is a one-file exception).
Related
This question already has an answer here:
Sharing data in between apps in IOS
(1 answer)
Closed 7 years ago.
I've been doing research on how to share data between applications securely. I'd like to get some info on the correct way to handle this before I do a deep dive on implementation using the wrong method. Just cause you can do something does not necessarily mean you should.
User Case: I am working on a suite of language learning apps that have a shared audio file base of several hundred audio files and json files containing important data corresponding to a language. I'd prefer to allow the user to not have to re-download the language bundle when they use another app in our suite.
1. App Extensions - Document Provider Non-UI Variant
According to the documentation:
The File Provider extension grants access to files outside the host app’s sandbox with the open and move actions. This extension (sometimes shortened here to file provider) also allows the host app to download files without presenting a document picker view controller. This feature lets the host app access previously opened documents using secure URL bookmarks, even if those files are no longer stored on the device.
On the surface this seems like a really solid solution. My main concern stems from the last couple lines where it state that the application can download the files no longer stored on the device. I want the files to be stored locally on the device to prevent constant downloading. If the Document Provider does store the files locally and allow the various applications in the group to access the files, then I think this could work.
2. Shared Keychain Access
Allows you to securely store data to a shared keychain that other applications that are part of a suite of applications can access. All applications that share keychain access must use the same app ID prefix. For an example of shared keychain access in action.
I've looked a little into the documentation of this one, and I think this might be the best fit. My major concern with this solution is whether or not there is a size limit to the data uploaded and if mp3/ogg/json file types are allowed. Most the examples/uses I have found with this solution point to sharing strings and small data, I am not sure if it will handle large data like json or audio files.
I also found this repo that apparently makes dealing with Keychain easier:
3. Custom Pasteboards
The custom pasteboard is best for the purpose of semi-privately sharing custom data between two applications. Custom pasteboards are identified using unique names. They can persist data beyond the application that creates them, allowing a pasteboard to hold onto data after the application is terminated or even after rebooting the device.
When writing or reading data to and from a pasteboard, you must specify a pasteboard type. Pasteboard types typically use a uniform type identifier (UTI) to identify the type of data going into and being retrieved from the pasteboard. See Apple’s UIPasteboard Class Reference documentation for additional information.
Above documentation pulled from this post
My main concern with this solution is that perhaps it is a bit of a hack. Logically a pasteboard seems like something that temporarily holds data and allows sharing between apps, whereas the solution I am looking for needs to be more of a permanent solution.
I'd appreciate any info on best practices towards sharing these types of files between apps. I assume there are plenty of other solutions I've omitted here, so if there is a better alternative I'd love some info on it. If it happens one of the listed solutions I have placed here is a good way to solve this problem I'd love to have some more info on your experience with working with them and if my concerns with them are valid, or nothing to worry about.
Thx in advance. As always, well written answers get up-votes ;)
I believe the best approach would be to enable data sharing by setting up an app group. This is Apple's recommended solution for sharing data between applications and extensions, and I believe for sharing data between apps in general.
See the section "Sharing Data with Your Containing App"
Also see "Adding an App to an App Group":
I'm trying to create a program that you can take a photo with your camera, and send it back, where it will then be attached as a field into an Oracle database. An existing app that this is similar to (if I'm not explaining it clearly enough) would be bank apps that allow you to photograph the front and back of your checks, then send them off to a different location to be processed.
From my understanding, I would need some sort of middleware and not access the database directly with the pictures taken, but I'm just trying to get the project off the ground at the moment.
So, my immediate questions are:
What sort of base project template would be the best to use for this kind of app?
What sort of code is required to send a file from one location to another? (I'm mainly used to these scenarios in .NET languages, not in xCode)
Expose an HTTP based service (and that can be written in any language and run on any platform e.g. GNU/Linux).
The app itself would be native iOS, and you can certainly consume web-services.
The server itself is just your basic CRUD system backed by a persistent store, in your case an RDBMS.
[iOS] <-----/net:HTTP/---->[server]<==/LINQ/==>[RDBMS]
I am working on In-App-Purchase and downloading data after payment in users /Documents folder. Apple has rejected my application it's says you are not following iOS Data Storage guideline.
Can any one help me how to implement iCloud functionality in my application?
Thank you
According to the iOS Data Storage Guidelines you should probably be storing your purchased data inside the Application_Home/Library/Caches directory. The downloaded data does not belong in the Documents folder.
Apple provides a list of the various directories and what you should put in those in the File System Programming Guide.
The most important includes:
Application_Home/Documents/ Use this directory to store user documents and application data files.
Application_Home/Library/ This directory is the top-level directory for files that are not user data files.
Application_Home/tmp/ Use this directory to write temporary files that do not need to persist between launches of your application.
Generally this means that anything that is not intended to be seen by the user should go into a directory inside the Library directory. Typically you would use one of these, but there is a larger list with more specialized uses in the File System Programming Guide:
Application Support: Use this directory to store all application data files except those associated with the user’s documents.
Caches: Use this directory to write any application-specific support files that your application can recreate easily
The Application Support folder is backed up but the Caches is not.
The answer is spelled out in the iOS Data Storage Guidelines, but it has downsides. It says clearly that the Documents directory is reserved for user-created content, and that the Caches directory is for content that can be downloaded again or regenerated. It's possible also that the size of the data factors into their approval. That answers your question, but it ignores the fact that it can be a burden for the user to re-download your data; argue your case and submit your feedback, but be prepared to change your download destination directory to the Caches directory.
iOS Data Storage Guidelines:
http://developer.apple.com/icloud/documentation/data-storage/
You also asked for info on iCloud functionality... data storage and iCloud APIs are two different things. Read here:
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iCloud/iCloud.html#//apple_ref/doc/uid/TP40007072-CH5-SW1
I need to make my app such that
the first screen will have the option : NEW and SEARCH.
2.Clicking NEW should allow the user to create a new profile,
3.but clicking search should allow to access one of the stored profiles by searching for the user number.
These profiles will actually be some data about the person, his name etc. and then yes/no answers to some questions.
At the moment my app works such that I can type in my name, and do the yes/no checks and I am using plists to save the info. this means that when the I start the app the next time the app loads with the saved info. So I have got half the task done.
Now how do I make it multi-user capable so that it has the option of creating a new file or providing a search option to access existing data?
also, I am creating the plist in application directory, using the code on apple's website, but I have no clue how to access these files directly..is it possible to access these files, if I want to show the information on a desktop? Thanks.
The key phrase you want for searching Apple's docs is: Data Management.
Specifically, I would recommend the Data Management Starting Point.
Handling data can be as simple as writing a string or array to disk or as complex as a big Core Data data model. If you plan on writing and maintaining several Apple API apps, I strongly recommend eventually learning Core Data.
I'm setting out to create an app where it will use 7-10 instances of a custom class, lets call them "books" each class will consist of a number of pages, a title, a int of how many pages a book contains and possibly some notes of the author associated with a specific page.
My question is what is the best way of creating these objects. it seems weak to just hard-code all the books together programatically, and if there are more added after the initial release I'd almost like to have the author be able to construct them with a simple desktop app.
So I guess what I'm looking for is a way to a create a small app to create instances of a custom class on a desktop, then bring those instances into the iphone app.
I only have an iphone dev license as far as I know. Obviously you don't have to be super specific but I'm looking for ways to accomplish this type of task. Maybe if there is a good way to go about hard coding them I would like to hear about that as well.
I guess an equivalent would be a game developer making like a level editor for his game so he doesn't have to create the boards programatically.
Provide your data in XML or JSON
format (or whatever flavour of file
format you prefer), this is to transfer data to/from application.
Parse your data file (xml/json) and store in permanent storage (file,sqlite,core data) on phone. This is the data that your application will regularly use from now on.
Offer user the option to get updates over network
If user selects to get updates, download updated xml/jason file over network, parse and update your permanent store
Use SQLite. You could easily create a sqlite database editor, or use some of the free ones out there. The iPhone can read a sqlite database natively, just include the library.