0

I am using SLComposeViewController to send a tweet. I have all the necessary permissions from Twitter to send a tweet, however, when I present the tweet sheet it never shows. From debugging my code I can see that the SLComposeViewController's completion handler is automatically called at SLComposeViewControllerResultCancelled is the result.

Has anyone come across this before? As I said, I have all necessary permissions and my Twitter account and password are set up correctly in my iPhone settings.

EDIT

This only happens sometimes. Majority of the time I have no problem with the Tweet sheet, so the code does work, but for some users they are experiencing this.

thanks

My code here:

- (void)presentTweetSheet {

SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
    switch (result) {
        case SLComposeViewControllerResultCancelled:
            SWLog(@"Tweet Cancelled");
            break;
        case SLComposeViewControllerResultDone:
            SWLog(@"Tweet sent");
        break;
        default:
            break;
    }
};

UIWindow *window = [UIApplication sharedApplication].keyWindow;
ECSlidingViewController *slidingVC = (ECSlidingViewController *)window.rootViewController;
[slidingVC.topViewController presentViewController:tweetSheet animated:YES completion:^{
    SWLog(@"Tweet sheet displayed");
    [self removeActivityIndicatorFromCell];
}];
}
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
Brian Boyle
  • 2,849
  • 5
  • 27
  • 35
  • You might want to revisit the rather hacky way of getting the current viewController. If I was you, I would entirely refrain from making assumptions on the current state of the application key-window. Also typecasting the current rootViewController towards your `ECSlidingViewController` without checking is a bit "ghetto"-style ;). – Till Feb 27 '14 at 13:16

1 Answers1

0

I checked multiple apps with the same code written in them, non of them worked. i tried sorting it out by code but it did not work. So i re-booted my iPhone and it WORKED! Hope this helps

Fahad Ajmal
  • 1,520
  • 1
  • 12
  • 15