Skip to content
clozach edited this page Oct 21, 2011 · 21 revisions

Configuration

ShareKit needs a fair amount of configuration to ensure that it works correctly. The most basic configuration necessary consists of the name and URL of your app. The section that most impacts the sharing functionality of your app is the credentials for the various sharers. Additionally, the ShareKit interface (colors, transitions, etc) can be configured.

API Keys

Most of the web services that ShareKit integrates require you to use an API key when connecting. An API key is a unique identifer that tells the service what app is making the request.

You have to sign up for each api key, but they are all free and sign-ups are quick. Here are some links that might help you get through the process even quicker.

Configuration Methods

There are two methods available to configure ShareKit. The first, using the preprocessor, is the easier of the two, but is only recommended for backwards compatibility with apps created before the second method. The second method, using a configuration delegate, is the currently recommended way to configure ShareKit.

At the top of SHKConfig.h, you'll find a list of services that require api keys. Each service has a link next to it. Follow the link for each service to get an api key.

Preprocessor Configuration

The original method of configuring ShareKit was to modify the provided SHKConfig.h header file. It contains preprocessor definitions for each configuration parameter. This method is still supported, but isn't recommended because it requires modifying the ShareKit source code, which is inconvenient when ShareKit is included as a git submodule in your project.

For those who wish to configure ShareKit this way, the configuration file is located at sharekit/Classes/ShareKit/SHKConfig.h. The comments around each preprocessor definition in the file explain the acceptable values.

Configuration Delegate Configuration

To avoid the issue of modifying the ShareKit source code when configuring, a configuration delegate can be used. The configuration delegate is an object that implements the SHKConfigurationDelegate protocol. This protocol specifies optional methods for all of the configuration parameters. The easiest way to use the configuration delegate method is to instead subclass DefaultSHKConfigurationDelegate. This class provides empty implementations for all of the methods in SHKConfigurationDelegate. Override the methods for which you have a custom configuration value.

Once the configuration delegation has been written, ShareKit needs to be made aware of its existence. This should be done as early as possible in your application's lifecycle, preferably in the applicationDidFinishLaunching: method of your UIApplicationDelegate. The necessary line of code is (assuming your configuration delegate is called MySHKConfigurationDelegate):

[SHKConfiguration sharedInstanceWithDelegate:[[MySHKConfigurationDelegate alloc] init] ];

Clone this wiki locally