ShareKit changes?
Asked Answered
S

6

7

I haven't used ShareKit much, but I want to have only three sharing options: Facebook, Twitter, and Email. ShareKit gives far more options, including a More button. However, I don't want the More option, just the three.

In SHKActionSheet.m of ShareKit:

// Add More button
[as addButtonWithTitle:SHKLocalizedString(@"More...")];

enter image description here

Spongin answered 16/6, 2011 at 12:18 Comment(0)
A
16

It is super easy now, if you use ShareKit 2.0.

  1. edit SHKSharers.plist to include only sharers you need. In case you do not want to compile unused sharers files, check granular install.

  2. You can hide "more..." button in configurator. The new setting is - (NSNumber*)showActionSheetMoreButton

  3. You can disable favourites reordering in configurator. Normally last used sharer is on the top in ShareKit's action sheet. The new setting is - (NSNumber*)autoOrderFavoriteSharers

Using this way you do not need to change or add any code to ShareKit.

Amendment answered 23/11, 2011 at 7:34 Comment(6)
I'm using SHK 2.0 and have done steps 1-3 above. With those changes, my desired services only show as I want them under More... (if that button is enabled). To get the services to show up on the initial action sheet, do I still need the code just above? Where does it go? In my view controller? Or do I have something else wrong? Or completely confused?Coupler
No, the code is not needed anymore. Maybe you did not set up default Favorites - It can be, that your services will show up in sheet only after you first time use them.Agitator
Thanks, I did this: - (NSArray*)defaultFavoriteURLSharers { return [NSArray arrayWithObjects:@"SHKMail", @"SHKTextMessage", @"SHKTwitter", @"SHKFacebook", nil]; } in my subclassed configurator. That should be sufficient? I've only been running in the simulator so far.Coupler
It should be sufficient. I will try to check with the demo app.Agitator
In + (SHKActionSheet *)actionSheetForType:(SHKShareType)type, NSClassFromString(@"SHKTwitter") returns nil. Any idea what might be wrong?Mccandless
you do not have loaded SHKTwitter class. Make sure, that you have setup your project properly, most importantly other linker flags. see sharekit 2.0 install wikiAgitator
S
4

I wanted to have the same thing. I spent days to make ShareKit work without too much success. Ok I was able to post FB, Twitter and Email messages but it was more pain the convenience.

Sharekit is an awesome idea but:

  • You cannot share image, URL and text at the SAME TIME! It has to be text only, URL only or Image only. Probably you want your user to post something on FB or Twitter or send an email about your App. What's the point if the message cannot contain an App Store or webpage link?
  • Very badly documented often you have to post questions on StackoverFlow
  • It's buggy, not supported by the original designer so there are dozens of forks. You can pick the ShareKit fork, but still.
  • On it's website it sounds like it's a drag and drop and you can make it work in minutes, good luck for that.

It takes 5 lines to add twitter, about 50 for Facebook and email to support text, URL and photo at the same time.

Twitter: This code sends a message with User editable text, URL (hidden, not editable) and an image. It took me 5 minutes to figure it out.

#import  <Twitter/TWTweetComposeViewController.h>

- (IBAction)twitterButton:(id) sender {
   TWTweetComposeViewController *tweetView = [[TWTweetComposeViewController alloc] init];
   [tweetView setInitialText:@"Check out this app, it's awesome" ];
   [tweetView addImage:[UIImage imageNamed:@"MyImage.png"]];
   [tweetView addURL:[NSURL URLWithString:appDelegate.appStoreURL]]; 
   [self presentModalViewController:tweetView animated:YES];
}

I really appreciate the effort of creating Sharkit but personally I cannot recommended it unless you really need to support all of those sharers and you happy with limited functionality.

UPDATE: I implemented Facebook sharing myself. It was more difficult than I thought. The main problem is that you cannot upload a photo with a post because Facebook only accept image links. Even worse Facebook does not allow to link to a photo which is uploaded to the user photo album (very easy) as it must be an external link. For static images you can use a URL shortener to get around it but for user generated images pretty much you have to use Amazon S3 or something else. Amazon S3 is super easy to use, I figured out how to use upload files in an hour or so.

Sycophant answered 1/3, 2012 at 9:1 Comment(0)
A
3

If you don't want the More... button, why don't you take out the line of code that adds it?

Agamogenesis answered 16/6, 2011 at 12:28 Comment(4)
ya good question my friend if i remove the that line of code it will shows only two options which are more frequent used because of that i mentioned earlier i don't know much about the ShareKit that's why i'm putting my question here i apologizes to mentions this point in my question hope now u understand my prob thanks ...Spongin
You're saying that if you comment out line 72 in SHKActionSheet.m (the line that adds the More button), then only two options appear? Which option disappears?Agamogenesis
when i'm comment out line 72 in SHKActionSheet.m (the line that adds the More button), then cancel button works as a more option in which line of code i will make a change to cancel work as a cancel not as more button thanx... How can we give a particular option in a particular view in action sheet like ShareKit example they are showing only email option in FileSharing(pdf) and giving other options in imageSharing how can we set these options on action sheet in a particualar View...Spongin
That's done in dismissWithClickedButtonIndex:animated:. Modify it not to make the last entry a special-case.Agamogenesis
P
1

you need to make this code changes from SHKActionSheet.m

+ (SHKActionSheet *)actionSheetForType:(SHKShareType)type
// Add More button
//[as addButtonWithTitle:SHKLocalizedString(@"More...")];


- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated

// More
//  else if (buttonIndex == sharers.count)
//  {
//      SHKShareMenu *shareMenu = [[SHKCustomShareMenu alloc]   
//          initWithStyle:UITableViewStyleGrouped];
//      shareMenu.item = item;
//      [[SHK currentHelper] showViewController:shareMenu];
//      [shareMenu release];
//  }

And you can edit SHKSharers.plist for services you like.

Padrone answered 28/10, 2011 at 9:49 Comment(0)
C
0

you can use the below definition for dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated

you need to delete the few lines which is commented in the below definition.

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
{
    // Sharers
    if (buttonIndex >= 0 && buttonIndex < sharers.count)
    {
        [NSClassFromString([sharers objectAtIndex:buttonIndex]) performSelector:@selector(shareItem:) withObject:item];
    }

    // More
    //else if (buttonIndex == sharers.count)
//  {
//      SHKShareMenu *shareMenu = [[SHKCustomShareMenu alloc] initWithStyle:UITableViewStyleGrouped];
//      shareMenu.item = item;
//      [[SHK currentHelper] showViewController:shareMenu];
//      [shareMenu release];
//  }

    [super dismissWithClickedButtonIndex:buttonIndex animated:animated];
}
Colly answered 19/10, 2011 at 19:27 Comment(0)
S
0

Excellent solution, however in my case for example want to use Facebook as well and there is no way to share content natively in iOS5. Another problem is that those who need the app compatible with iOS4.0 or higher (my case) can not, because this method only works from 5.0.

How to solve this? ShareKit to Use Facebook and Twitter for the native methods and forget about compatibility with iOS4.0?

Semolina answered 4/3, 2012 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.