Tuesday, July 9, 2013

Twitter Integration in IOS 5 using Twitter Framework +iPone



1 :- Add Twitter.framework
2 :- open ViewController.m and add the following import at the top of the file:
#import <Twitter/Twitter.h>

- (IBAction)twitterButtonClicked:(id)sender {
    {
        if ([TWTweetComposeViewController canSendTweet])
        {
            TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
            [tweetSheet setInitialText:
             @"Your tweet Message"];
            [self presentModalViewController:tweetSheet animated:YES];
        }
        else
        {
            UIAlertView *alertView = [[UIAlertView alloc]
                                      initWithTitle:@"Notification"
                                      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];
        }
    }
}

No comments:

Post a Comment