Can I use Keychain Across iPhone Apps, from an SDK? - iphone

I am writing an SDK which will ship as a static library. Can I access the keychain to store data so that I can retrieve it in another app which also has my library? Seems like Apple would frown upon this, since I did not sign the apps, but am merely a passenger in the app's code.
Was looking at using "SFHFKeychainUtils" to help implement this. Any thoughts?

AFAIK, the keychain can only be shared across apps with the same Bundle Seed ID (which would be controlled at the signing level, as you say). As such, the only apps that would be able to share keychain access would be apps from any single developer. Cross-developer sharing is a no-go.
Check out more iOS security info here in Apple's docs.

Related

Is there a neat way to tell if iPhone/iPad has been set a passcode by user

I have asked this question long before.
I know it maybe impossible, but as far as I know, 'Find my friends' has this features and it works just so well, so I wonder if now there is a neat and legitimate way of doing that.
Just because Apple's Find My Friends app has a feature does not mean the API is publicly available. If this app is not an enterprise app, you can't use private APIs and have your app put on the app store. If it is an enterprise app, you may want to look into setting up a configuration profile for the device. In order to access the VPN for my employer, I had to install a configuration profile (visible in Settings) that requires a passcode to be entered every time I unlock my iPad. Without that, I cannot VPN into their intranet. TestFlight uses a similar approach with profiles to register a device to receive builds. I would check out this link from Apple on setting up these sorts of profiles for enterprise applications: http://www.apple.com/iphone/business/resources/
There's no way to detect this programmatically from within an iPhone SDK-based application. If you need to, you should file an enhancement request with Apple at http://bugreporter.apple.com

Is there a way to directly download an iOS app (without using the app store)

I would like to have users be directed to a link which will immediately start downloading an app on an iOS device. I know you can register for Enterprise application or do limited ad-hoc distribution, but this is not the case here. The app I would like to link to is already on the app store. I would like to know if users can download the app directly without going through the app store.
Thanks in advance.
As mentioned above, you cannot provide a direct link to the application. There are ways of circumventing the app store, such as ad-hoc distribution and ADC's enterprise program. However, neither of these would provide the convenience you seek as potential users would have to install certificates generated by you before installing your application. Your best option would be to use the app store or possibly a web app.As David V mentioned, you can provide a direct link to your app in the app store!
Good luck,
-Alex
They will need to go through the App Store. You can provide them a link to your app in the App Store though.
In fact, even in jailbroken devices, you need to use a store. Apple seems not to have a auto-installing url scheme implemented.
Would be nice, though.
No. This is not possible on stock OS iOS devices
You can do that if your app is based on Safari (web app) instead of native (iOS).

In App Purchase Content for a Different App

I currently have an app that is divided into multiple apps. I'd like to combine them all into a single application with the ability to use In App purchasing to download the parts currently held in multiple apps. Is there a way that I can allow people who currently own the individual apps to somehow make an In App purchase that unlocks the parts in the single app?
The most obvious solution is to use a web server holding user accounts and in-app purchases. If you require an offline solution, I will suggest you to use iCloud Keychain, you can mark your apps sharing the same keychain in XCode.
To enable keychain sharing:
-Select the target in XCode
-Go to capabilities
-Enable keychain sharing
-Add a group with same name for all apps.
After all your apps will be able to reach this shared data.
If you are not familiar with keychain this tutorial will be a good start. Keychain is not that complicated.
EDIT: woops didn't even notice I'm answering a 3 year old question.

Can keychains in IOS be compared to DPAPI in Windows?

On iOS, I am looking for an API equivalent to the encrypt/decrpyt DPAPI functions available on Windows (with CRYPTPROTECT_LOCAL_MACHINE flag not set).
The objective is to persist some application data locally and making its access restricted to the application itself only.
I've read about the keychain functionality but it seems that the dictionary has user-level access (unlocked during smartphone logon). I would like the application to be the only one who has access to that information, like, typically, having its own keychain.
Any advice on this?
An app cannot access another app's keychain entries in iOS. In principle, it's as if each app has its own keychain.
In iOS, an application can always access its own keychain items, but
not items created by any other application.
http://developer.apple.com/library/mac/#documentation/Security/Conceptual/keychainServConcepts/02concepts/concepts.html
However, see this post for other keychain security concerns.

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/