Skip to content
VilemKurz edited this page Jul 12, 2012 · 29 revisions

Q: I have added ShareKit to my project as submodule. How can I update it?

A: It is done in terminal. Assuming you are in your project' root directory, go to ShareKit directory:

cd Submodules/ShareKit

and download newest version of ShareKit:

git checkout master
git pull

It can happen, that also ShareKit is using newer version of its submodules, or some new are added. Make sure you download them too(*):

git submodule init    
git submodule update

Now you should tell your project, that ShareKit has been updated. Go to back your project root:

cd ../..

Your project git repo treats submodules as a reference to particular commit - now git updates the reference to actual ShareKit's commit:

git add Submodules/ShareKit
git commit -m 'ShareKit updated to the newest version'

(*) if you look at some of the submodules original repo on github (say facebook-ios-sdk), you may notice, that there is newer commit, than that you got with submodule update. This is because submodule update does checkout submodule to the commit specified in ShareKit, which may not be the latest in original submodule's repo.

Q: How can I customize ShareKit's action sheet? I do not need "more..." button and just need to always show some specific services only. Say Twitter, Facebook and Mail.

It is super-easy now:

  1. copy SHKSharers.plist , give it different name and include only sharers you need. Add it to your project, and set it in your DefaultSHKConfigurator subclass in - (NSString*)sharersPlistName. This way you do not need to change original SHKSharers.plist and can upgrade (pull) easily.
  2. set desired sharers in configurator, in favorite sharers section. Otherwise you will see only those left from default setting.
  3. You can hide "more..." button in configurator. The setting is - (NSNumber*)showActionSheetMoreButton
  4. You can disable favourites reordering in configurator. Normally last used sharer is on the top in ShareKit's action sheet. The setting is - (NSNumber*)autoOrderFavoriteSharers

Q: Is it possible to make the shared item text or other properties slightly different for each sharer service?

A: YES. You can create your own subclass of SHKActionSheet, and override

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animate
{
    NSString *sharersName = [actionSheet buttonTitleAtIndex:buttonIndex];    
    [self changeItemForService:sharersName];
    [super dismissWithClickedButtonIndex:buttonIndex animated:animated];  
}

- (void)changeItemForService:(NSString *)sharer
{
    if ([sharer isEqualToString:@"Facebook]) {
        self.item.text = @"whatever";
    }
}

AND if you use "More..." button you should use subclass SHKShareMenu too, and analogically override

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSDictionary *rowData = [self rowDataAtIndexPath:indexPath];
    if ([[rowData objectForKey:@"name"] isEqualToString:@"Twitter"]) {
        self.item.text = @"whatever";
    }
    [super tableView:tableView didSelectRowAtIndexPath:indexPath];
}

if you do this, you should override

- (Class)SHKActionSheetSubclass;
- (Class)SHKShareMenuSubclass;

methods in your configurator and return names of your custom subclasses.

Q: How can I contribute to the project?

  • the biggest help is to test, or at least review pull requests. The more people test or judge pull requests, the greater is the speed of innovations. The better ShareKit becomes. How to test a pull request:
    1. Make and checkout a new test branch from master on your repo.
git checkout master
git branch test<Feature>
git checkout test<Feature>
2. Synchronize it with upstream master (ShareKit's master), so that it is up to date
git fetch upstream
git merge upstream/master
3. add remote pull requester's fork to your git repo as a remote
git remote add <requester> [email protected]:<requester>/ShareKit.git
4. find pull request's branch and pull this branch to your new test branch
git fetch <requester>
git merge <requester>/<pull request's branch>
5. test and give feedback
  • compare your language's localizable.strings file with english. If there are some strings missing, please add them and make a pull request. You do not have to got through the whole english file - the newly added strings should be at the end of the english file. If your language is missing, please consider making a translation.
  • read through the issues from time to time. Some of them are not issues, but new ideas. You can express an opinion - is it useful? Or harmful? Too specific or too complicating?? Why do you think so?
  • if you see some issues you can help to resolve, do so.
  • if you have any issue, crash etc please report it (if possible, include crash report too)
  • if you think of some enhancement, or missing feature, open an issue.
  • if you have any pull request on original ShareKit, or made an adjustment on your fork, and think that it would be benefit for the community, feel free to open a pull request

Q: I would like to add a new sharer. Where to start?

All the necessary information is here.

Q: I see ShareKit is translated to many languages. I have noticed, that in my app ShareKit speaks only languages my app speaks too.

You must set CFBundleAllowMixedLocalizations (or "Localized resources can be mixed” in XCode) to YES to allow frameworks to use extra languages.

Q: Is there any way to find username logged in each service?

Yes. There are two ways services interact with ShareKit - some store credentials in user's keychain, some do not. If they do not, you have to fetch available user info (e.g. username):

[SHKFacebook getUserInfo];

or

[SHKTwitter getUserInfo];

The user info is then fetched and stored in kSHKUserInfo> key in NSUserDefaults. You might want to wait for @"SHKSendDidFinish" notification and then update your UI. Some examples how to retrieve actual user names are bellow:

Facebook:

    NSDictionary *facebookUserInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"kSHKFacebookUserInfo"];
    NSString *fbUserName = [facebookUserInfo objectForKey:@"name"];

Twitter (pre iOS 5. In iOS 5 you have to ask account framework for available twitter users):

    NSDictionary *twitterUserInfo = [[NSUserDefaults standardUserDefaults] objectForKey:@"kSHKTwitterUserInfo"];
    NSString *twUserName = [twitterUserInfo objectForKey:@"screen_name"];

basic (non OAuth) sharers (sharer ID is a name of the sharer's class, e.g. SHKTumblr):

    [SHK getAuthValueForKey:@"username" forSharer:sharerId];

or some sharers (Tumblr, Google reader) use email as username:

    [SHK getAuthValueForKey:@"email" forSharer:sharerId];

Q: How can I enable thorough debug console output for ShareKit?

Uncomment line 33 in DefaultSHKConfigurator.h

Q: Can I enable auto–share for certain services?

Yes. Some sharers is auto-share disabled by default. The easiest way to enable auto–share is to create a class Category for each SHKSharer and override - (BOOL)shouldAutoShare method. For example:

// SHK+Autoshare.h
#import "SHKTwitter.h"
#import "SHKFacebook.h"

@interface SHKTwitter(Autoshare)
@end

@interface SHKFacebook(Autoshare)
@end
// SHK+Autoshare.m
#import "SHK+Autoshare.h"

@implementation SHKTwitter(Autoshare)
- (BOOL)shouldAutoShare { return YES; }
@end

@implementation SHKFacebook(Autoshare)
- (BOOL)shouldAutoShare { return YES; }
@end

Q: Is there a flowchart of ShareKit's workflow?

Yes. You can find them in downloads section. They are of high level, some details are simplified in order to get an overall picture how SHK works. White objects are a functionality of base sharer classes (SHKSharer and SHKOAuthSharer. Blue objects are the responsibility of specific sharer subclasses. Yellow are settings from DefaultSHKConfigurator.

Clone this wiki locally