3

I'm using ShareKit 2 on an iOS app for version 5 or later. I've got the app configured to use Facebook correctly, and when the action sheet is activated, that's the only option that appears. I want to use the built-in Twitter sharing system, but the option doesn't come up in the action sheet. Here's my code:

SURL *url = [NSURL URLWithString:launchUrl];
SHKItem *item = [SHKItem URL:url title:@"Title" contentType:SHKShareTypeURL];

SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

[SHK setRootViewController:self.view.window.rootViewController];

[actionSheet showInView:self.view.window.rootViewController.view];

As per the instructions. I've got a custom DefaultSHKConfigurator class, in which I suppose these are the relevant methods:

- (NSString*)sharersPlistName {
   return @"MySHKSharers.plist";
}

- (NSArray*)defaultFavoriteURLSharers {
   return [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook", @"SHKMail",  @"SHKTextMessage", nil];
}

Again, only Facebook comes up as an option. For completeness, here's my "MySHKSharers.plist" file (the relevant part):

<dict>
<key>actions</key>
<array>
    <string>SHKMail</string>
    <string>SHKTextMessage</string>
</array>
<key>services</key>
<array>
    <string>SHKTwitter</string>
    <string>SHKFacebook</string>
</array>
</dict>

So any ideas why I can't get Twitter, Mail and TextMessage to show up in the action sheet?

Aaron Vegh
  • 5,217
  • 7
  • 48
  • 75

2 Answers2

4

If you want to configure the sharers shown in the actionsheet I found this post helpful:https://gist.github.com/1181552

I ran into trouble getting actions (email, text message, etc) to show in the default actionsheet. My solution was to create a custom actionsheet and then to call Sharekit like this:

- (IBAction) getSharingSheet:(id)sender{
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Share"
                                                    delegate:self
                                                    cancelButtonTitle:@"Cancel"
                                                    destructiveButtonTitle:nil
                                                    otherButtonTitles:@"Facebook", @"Twitter", @"Save to Photo Library", @"Email", nil];
    [sheet showInView:self.view];
}

and then my didDismissWithButtonIndex:

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    switch(buttonIndex)
    {
        case 0:
            SHKItem *item = //some item
            [SHKFacebook shareItem:item];
            break;
        case 1:
            SHKItem *item = //some item
            [SHKTwitter shareItem:item];
            break;
        case 2:
            SHKItem *item = //some item
            [SHKPhotoAlbum shareItem:item];
            break;
        case 3:
            SHKItem *item = //some item
            [SHKMail shareItem:item];
            break;
        default:
            break;
    }
}

Hope this helps!

kevinstueber
  • 2,926
  • 3
  • 26
  • 26
1

I had this same issue and just solved it. This may or may not be the same issue that you are facing.

After poking around a bit to see how the action sheet was being built, I found that in SHK.m it was pulling stored favourites out of NSUserDefaults.

+ (NSArray *)favoriteSharersForType:(SHKShareType)type
{
    NSArray *favoriteSharers = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"%@%i", SHKCONFIG(favsPrefixKey), type]];
   ....
}

These stored results are preferred even over what you've defined as the "default" favourite sharing services. Clearing out these favourites solves the issue.

bengoesboom
  • 2,119
  • 2
  • 23
  • 27