Keychain group access

Source: Internet
Author: User

From: http://useyourloaf.com/blog/2010/04/03/keychain-group-access.html

Since iPhone operating system 3.0 it has been possible to share data between a family of applications. this can provide a better user experience if you follow the common path of free (free)/Premium (charged) applications or if you have a set of related applications that
Need to share some common account settings.

The main pre-requisite (prerequisite) for shared keychain access is that all of the applications have a common
Bundle seed ID. To be clear what this means remember that an app ID consists of two parts:

<Bundle Seed ID> . <Bundle  Identifier>

The bundle seed ID isA unique (within the App Store) Ten character stringThat is generated by Apple when you first create an app ID. The bundle identifier is generally set to be a Reverse Domain Name string identifying your app (e.g.
Com. yourcompany. appname) and is what you specify in the ApplicationInfo. plistFile in xcode.

So when you want to create an app that can share keychain access with an existing app you needMake sure that you use the bundle seed ID of the existing app.You do this when you create the new app ID inIPhone provisioning
Portal (iPhone configuration portal ).
Instead of generating a new value you select the existing value from the list of all your previous bundle seed IDs.

One caveat (note it), whilst (though) You can create a provisioning profile with a wildcard (wildcard) for the bundle identifier I have never been able to get shared keychain access working between apps using it. it works fine with fully specified (no wildcard)
Identifiers. since a number of other Apple services such as push notifications and In-APP purchase also have this restriction maybe it shocould not be a surprise but I am yet to find this incluented for keychain access.

Once you have your provisioning profiles setup with a common bundle seed ID the rest is pretty easy. the first thing you need to do is register the keychain access group you want to use. the keychain access group can be named pretty much anything you
Want as long as it starts with the bundle seed ID. So for example if I have two applications as follows:

  • Abc1234def.com. useyourloaf. amazingapp1
  • Abc1234def.com. useyourloaf. amazingapp2

I cocould define a common keychain access group as follows:

  • Abc1234def. amazingappfamily

To enable the application to access this group you needAdd an entitlements plist file to the project using xcode. Use add-> New file and select the entitlements template from the iPhone OS code signing section. You can name
File anything you like (e.g. keychainaccessgroups. plist). In the file Add a new array item named keychain-access-groups and
Create an item in the array with the value of our chosen keychain access group:

Note: do not change the get-task-allow item that is created by default in the entitlements file unless you are creating an ad-hoc distribution of your app (in which case you shoshould uncheck this option ).

This same process shoshould be repeated for all apps that share the bundle seed ID to enable them to access the keychain group. to actually store and retrieve values from this group requires adding an additional value to the dictionary passed as an argument
To the keychain services. Using the example from the previous post on simple iPhone keychain access the search dictionary gets the following additional item:

[searchDictionary setObject:@"ABC1234DEF.amazingAppFamily"                      forKey:(id)kSecAttrAccessGroup];

One final comment, using a shared keychain Access Group does not stop you from storing values in an applications private keychain as well. The apple generickeychain example
Application builds two applications which both store data in a private and group keychain.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.