How to share data between applications in iphone - iphone

I have created one app. It is an update of another application. I have to use the data of first application when launching the second application. How can I accomplish this? My database files are with the same names.

iPhone apps are sandboxed. You can't access any other app's documents folder. Not even your own ones. You can share keychains between your apps or you can open other apps with an argument or a document. That's about it.

In addition to the aforementioned keychain sharing:
How to share keychain data between iOS applications
, if you involved a server, you could use the server as a mediator to exchange information between the two sandboxes.
It is also possible to have one application send another file to another application (although this results in a copy from one sandbox to the other) via registered mime types:
How do I associate file types with an iPhone application?
You can also share information via URL handlers.
http://mobileorchard.com/apple-approved-iphone-inter-process-communication/

Related

Creating an iOS application which is distributed to limited selected audience

I just started creating custom client application for IOS, Which i have already developed for PC and Android clients. Idea of these apps is to use SQLite database file, which is created in PC admin app and is actualized by Internet. Development of this application is payed from one company and shoud be distributed to selected group of people.
What i want to ask is how to distribute this IOS application to certain audience of people (who has right to use it)? Should I put it on app store as free app without database file which should be downloaded to iphone from secret site?
The best way to do it is via the iOS Developer Enterprise Program.
As for the data, you could link it to a web API if the data is growing or changing regularly. But for static data, you could distribute it by including it in the application itself. See CoreData and other tools for more information.
You can also release it for free on App Store and provide a custom login. However, this is not recommended as this application is useless for the rest of the world. The only reason you would want to do this is if your custom clients can register on your website or some place else and you want to allow them to access the app. This is generally done for subscription based applications. But I presume yours is not such a case.
There is also Ad Hoc distribution, but with that you are limited to 100 devices.
You can read more about distribution.
Note: this may not be the bust way but here is my solution for it
I established a server and set user credentials on the server before, i share credentials with the client and he/she logs in with them.. Later they can edit their credentials, my app is on the store for any body but someone who doesnt have those credentials can't log in..
What you're trying to do is this:
https://developer.apple.com/programs/ios/enterprise/
An ad-hoc distribution is your solution.
https://developer.apple.com/programs/ios/distribute.html
If you're planning to distribute the app to more than 100 people, go for their Enterprise program:
https://developer.apple.com/programs/ios/enterprise/

iPhone "Share" button

Is there anything like the Android's "Share" button in iPhone?
I am just starting out in iOS development and do not have an iPhone (yet). The idea is to be able to select documents or images saved on the phone and use them in my app. I realize there is an ImagePickerController but that is not what I am looking for. I am also not looking for a third party component, rather something integrated into the OS similar to Android.
Short answer: No.
You can register your app to handle certain file types, and files of those types can then be opened by your app via UIActionSheets that may appear, for example, when you tap and hold on a file in an email. You can also transfer files to your app via iTunes. There's no 'file explorer' type feature in iOS where you can pull up a view of files saved to your phone.
For images, as you mentioned already, you must use UIImagePickerController.
From documentation
Sharing Files with the User
Applications that want to make user data files accessible can do so using application file sharing. File sharing enables the application to expose the contents of its /Documents directory to the user through iTunes. The user can then move files back and forth between the device and a desktop computer. This feature does not allow your application to share files with other applications on the same device, though. To share data and files between applications, you must the pasteboard or a document interaction controller object.
You can read more here:
https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StandardBehaviors/StandardBehaviors.html%23//apple_ref/doc/uid/TP40007072-CH4-SW7

How to distribute iphone apps in-house with various content?

I'm developing an iPad app that will be distributed in-house using the Enterprise Program membership. However, "in-house" means distributed to various worldwide locations.
The app binary itself will be universal for all content, client locations worldwide. However, the content (an SQLite DB file) will vary between devices. One iPad in UK has the English content file for a product, whilst another in France has the French content for a different product loaded.
The plan is to send the different client locations their content so that they can connect their devices to iTunes, install (or update, important!) the app and then copy the SQLite DB file to the device.
Can we do this, and how will it work? What are the limitations?
Acceptable answers must include the following:
Confirmation and description on how the SQLite content file can be synced
Confirmation and description/resource on how the distribution will work
I've found one somewhat related question:
Distributing database updates to an iPhone application without downloading the whole database
Would it be ok to have the App start up in a "neutral" mode?
Show icons for the different content types (Language Flags perhaps), and when you touched one, it would download from your server the appropriate data pack.
If certain users are only allowed certain content, maybe you could send them an out-of-band URL or password that they enter to get their personal content.
That way the App distro is always identical, and your server manages the customization packs.
I've now completed the project and can confirm that this technique is perfectly valid. We are distributing the application and SQLite database file along with the content (image and video) to the clients, which by the way has to enter the Enterprise Program themselves. The clients install the application via iTunes in an ad-hoc-manner, and then copy the database file and content files to the iPad in the iTunes interface.
The distribution itself is very straightforward, since the application package we are sending the clients are signed and provisioned. They won't encounter any issues with installing and updating, all they need is the free iTunes account and our application related files.
Different client's iPads can have different content. Updating the content or database file is quick and easy. Updating the application is also easy, just remind the clients to delete the app before adding the new version to their iTunes Library.
Finally a tip; if you're getting an error in iTunes (which BTW don't make sense) about your Entitlements when installing the app - add an application icon.

Updating resource files for iPhone app

I've developed a generic iPhone app, intended for customization via a myapp.cfg file. I've successfully deployed the app to my adhoc testers via iTunes. My question is, how do I update their myapp.cfg file via iTunes. In other words, if they edit the .cfg file on their Windows PC or Macbook, how do they get it into the apps bundle in the iPhone?
You'll need to provide your own mechanism to download the config file into the application's Documents area; as app bundles are effectively sealed by the code signing process there's no way to modify the bundle post facto. As you have no interface to iTunes you need to provide your own mechanism - you might choose to do something like OmniFocus which uses Bonjour to discover the computer from which it retrieves its sync settings.
Looking at it another way; why use a config file at all? Other iPhone applications use a settings bundle and the standard application preferences as recommended by Apple, why do something different? There's always a chance that you'll confuse the user.

How to use another app's settings

What code could I use in an iPhone app to get and set the settings of another app I wrote? (preferably using NSUserDefaults)
You're not going to be able to pull this off with NSUserDefaults.
The Keychain, while somewhat cumbersome in its C-ness and much more limited than the NSUserDefaults API, might allow you to accomplish this. If you can serialize whatever you need to share between your apps into a few strings, it might be worth trying.
From iPhone OS 3.x Release Notes:
It is now possible for you to share Keychain items among multiple applications you create. Sharing items makes it easier for applications in the same suite to interoperate more smoothly. For example, you could use this feature to share user passwords or other elements that might otherwise require you to prompt the user from each application separately.
Sharing Keychain items involves setting up the proper entitlements in your application binaries. Using Xcode, you must create an Entitlements property list file that includes the supported entitlements for your application. The process for creating this file is described in iPhone Development Guide. For information about the entitlements you can configure, see the description for the SecItemAdd function in Keychain Services Reference.
Accessing shared items at runtime involves using the Keychain Services programming interface with the access groups you set up during development. For information about how to access the Keychain, see Keychain Services Programming Guide.
Here's Buzz Anderson's Simple iPhone Keychain Code. You could use it to store key/value pairs as strings in the keychain. It's not much, but perhaps better than nothing. See Apple's Keychain Programming Guide for more.
You simply cannot do that. Each application is installed into its own folder and is given its own, unique user id. The file containing these settings is in the other application's folder and its permissions are set to that of the other application. The only way to access the data is to use the same application identifier as the other application, in which case installing your application would overwrite the old application.
EDIT:
This solution was given when the question was asking to do this using NSUserDefaults, specifically. For the updated question, the keychain approach or the server approach provided are both reasonable.
You can have one app send the data to your server, then the other app can get the data from your server.
You can't do this using NSUserDefaults but it can be done.
You could use a shared clipboard. It wouldn't be secure, but both apps could read and write from the same clipboard. You just need to create an application specific UIPasteboard. Check out the UIPasteboard class reference on Apple's developer site for more info.
--Mike
You should definitely have a look at UIPasteboard, as suggested – you can create a new pasteboard for use by the applications you are creating (though nothing will stop other apps using them, but people are faily unlikely to). A UIPasteboard is persistent through a power cycle / reboot – it will exist until the creating application is deleted.
You could also have a look at the SwapKit libary (which looks very cool):
http://infinite-labs.net/swapkit/