How to use SLComposeViewController for reply twitter post in iOS?

594 Views Asked by At

I am currently working on integrating twitter to my app,i try to do some research about reply twitter post.I know how to do it using SLRequest but its has no UI. So, I want to use SLComposeViewController ui for reply. Do you guys any suggestion? Thanks!

1

There are 1 best solutions below

3
On

In the case of replying to a specific tweet, check out this answer here: Is there a way of replying to a particular tweet via SLComposerViewController

So in addition to using the SLComposeViewController, like you would below, you will need to pass a few additional parameters including "in_reply_to_status_id". The above link explains this in detail.

You would want the reply button to trigger something like this:

-(IBAction)TweetPressed{
  if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
  {
      SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
      [tweetSheet setInitialText:@"@USERNAME_TO_REPLY_TO"];
      [self presentViewController:tweetSheet animated:YES completion:nil];

  }
  else
  {
      UIAlertView *alertView = [[UIAlertView alloc]
                                initWithTitle:@"Sorry"
                                message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
                                delegate:self
                                cancelButtonTitle:@"OK"
                                otherButtonTitles:nil];
      [alertView show];
  }
}

There is a full tutorial available here: http://ios-blog.co.uk/tutorials/integrating-social-media-in-your-apps/