share text on facebook from iOS application using sharekit - iphone

I want to share some text on facebook using sharekit. I found many solutions but no1 worked for me.
I have imported sharekit and frameworks in my project. Now I want to share text: #"Hello everyone" directly (I mean not to choose from options: mail, twitter, facebook. When I press button share it should share text on facebook, of couse ask log in if it's necessary).
And also I will be glad if you tell me which fields are necessary to fill in the SHKConfig.h file for facebook.

In DefaultSHKConfigurator.m replace the defaultFavoriteTextSharers method with the below Code
- (NSArray*)defaultFavoriteTextSharers {
return [NSArray arrayWithObjects:#"SHKFacebook", nil];
}

Sharing Text
+ (SHKItem *)text:(NSString *)text;
//text - The text you want to share
NSString *someText = #"This is a blurb of text I highlighted from a document.";
SHKItem *item = [SHKItem text:someText];
You can download the ShareKit source files and just watch the ShareKit official project overview video here
You can read the ShareKit documentation here

Related

Google plus share opens link in browser

I am just trying to implement an iPhone app, that has a feature to share on Google+. So, when I click on share button, it is opening the link in safari. Instead, I would like to have it like Facebook pop-up window. Is there any possibility to implement it?
- (IBAction) didTapShare: (id)sender {
share = [[[GooglePlusShare alloc] initWithClientID:kClientID] autorelease];
/* share.delegate = self; // optional
appDelegate.share = share; //optional*/
[[[[share shareDialog] setURLToShare:[NSURL URLWithString:#"URL_TO_SHARE"]] setPrefillText:descStr] open];
[[share shareDialog] open];
}
This is the code, I’ve used for sharing. And I look up on the GooglePlusShare class, I couldn’t figure out anything possible. Thanks in advance!
I think , right now , this is the preffered way to post on google plus..And
After all. after posting status on google plus..it also comes back to your app..

ShareKit changes?

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...")];
It is super easy now, if you use ShareKit 2.0.
edit SHKSharers.plist to include only sharers you need. In case you do not want to compile unused sharers files, check granular install.
You can hide "more..." button in configurator. The new setting is - (NSNumber*)showActionSheetMoreButton
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.
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.
If you don't want the More... button, why don't you take out the line of code that adds it?
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.
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];
}
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?

Sending Text and Image in one Email via ShareKit

In iPhone App I want to send Image and Text together in single Email Using ShareKit
is it possible to do so?
If yes, How can it be done?
This is what I use:
SHKItem *item = [SHKItem image:myImg title:#"My Awesome Image!!!"];
item.text = #"Look at this awesome Image";
[SHKMail shareItem:item];
and it works well!
ShareKit doesn't seem to have very comprehensive documentation, but from what I could find, it seems your best bet is to share an image and include your text as the title - as an e-mail, this should just work as 'sending an image with text'.

iOS ShareKit, twitter logout? facebook status empty?

I am using ShareKit plugin for iPhone to enable social sharing for the application I'm working on. I set up everything, I stripped it to have Facebook and Twitter services only, connected successfully to both and now I have 1 problem in each of the services...
The problem with Twitter is how to logout/signout...
ShareKit sends the text and the url to Twitter's publish box. It is saving status perfectly. The question is where to put "logout" button for twitter? I want the iPhone user to logout in order to change username. This is done by calling the method
[SHKTwitter logout];.
Now, the problem is where to put the button that will fire this method? In navigationToolbar of Twitter actionSheet I already have 2 buttons and the toolbar (bottom one) is covered by the keyboard?
[EDIT]: I solved this issue by modifying the twitter action sheet. I resized the textView and then added UIToolbar and changed its position so that it fits into the gap between the keyboard and textView. Into the toolbar I added one button with an action that calls a logoutTwitter method
Facebook problem is more of a mystery...
So, in my sharreKitButtonHandler I have the following code:
NSURL *url = [NSURL URLWithString:#"http://www.domain.com"];
SHKItem *shareItem = [SHKItem URL:url title:self.itemTitle.text];
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:shareItem];
[actionSheet showFromToolbar:self.shareKitToolbar];
This code prepares some ivars of a shareItem object and in the case of Twitter shareKit manages to fill the status box so that user just needs to press publish and its done...
In the case of Facebook it is not working. FB dialog pops out and the share box is empty saying "What's on your mind?" The url and the title are not put into the publish form?
So, please if you have any clue what's going on in the latter problem or how to solve the former problem, I would really appreciate your help...
It takes five lines to add twitter. I wouldn't bother with Sharekit for that.
TWTweetComposeViewController *tweetView = [[TWTweetComposeViewController alloc] init];
[tweetView addImage:imageToShare;
[tweetView addURL:URLToShare];
[tweetView setInitialText:messageToShare];
[senderViewController presentViewController:tweetView animated:YES completion:nil];
I wanted to use sharekit for my projects, but it was difficult to use and after a week I gave up as I couldn't share more than one thing at the same time (URL, Image, Message, etc.) which is pretty useless if you want to promote your app.
Facebook is more difficult, probably a 100 lines. It took me 3-4 days to implement. It will be integrated in iOS 6 just like Twitter :)

Google Calendar Mobile Version - embed

I want to embed a google calendar into an iphone app, my webview is fine, except I can't seem to get the URL I need to view the mobile version without having to logging in.
I know its possible as this is done in the twit app (See Screenshot below).
How can I do this?
Lets say the public google calendar is link text and I want to view the Mobile version of this page in a UIView.
The mobile view is available at link text, but you must first be logged into a google account.
Help Stackoverflow!
alt text http://posterous.com/getfile/files.posterous.com/norskben/RtIkoblEW9VsBE07dAQy9Sjjo4aRL2yjCRTCIx316y7ovsCXo9iKeGLL1AMx/photo.jpg
All under control now. Although I didn't find it possible to access the gp mobile view, it turned out infact to be just the agenda view of the normal view.
NSString *gcal = [NSString stringWithFormat:#"<html><meta name=\"viewport\" content=\"width=320\"/><iframe src=\"http://www.google.com/calendar/embed?showTitle=0&showNav=0&showTabs=0&showPrint=0&showCalendars=0&mode=AGENDA&height=600&wkst=2&hl=en_GB&src=northadelaidefitness#gmail.com&color=%23A32929&ctz=Australia%2FAdelaide\" style=\"border-width: 0pt;\" mce_style=\" border-width:0 \" frameborder=\"0\" height=\"400\" width=\"300\"></iframe>"];
[webview loadHTMLString:gcal baseURL:nil]; //load above html string (notice the viewport=320 for iphone resizing
webview.delegate = self; //add delegate for activity access
webview.scalesPageToFit =YES; //scale nicely