Brjv
Brjv

Reputation: 1074

How do I post image and text to Twitter via Twitter native app?

How do I post image and text to Twitter via Twitter native app ?

Is there any Twitter api to tweet via native Twitter app in IOS programmatically ?

or , How can I post image using Social or Twitter framework via Twitter native app?

Thanks

Upvotes: 0

Views: 446

Answers (2)

Soumya Ranjan
Soumya Ranjan

Reputation: 4843

Please Try this answer. I think this will help u

  - (void)postToTwitter
 {
SLComposeViewController *tweetSheet=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
//     if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
//     {
SLComposeViewControllerCompletionHandler __block    completionHandler=^(SLComposeViewControllerResult result){

    [tweetSheet dismissViewControllerAnimated:YES completion:nil];

    switch(result){
        case SLComposeViewControllerResultCancelled:
        default:
        {
            NSLog(@"Cancel");
        }
            break;
        case SLComposeViewControllerResultDone:
        {
            NSLog(@"Post");
        }
            break;
    }
};

[tweetSheet setInitialText:@"your text"];
[tweetSheet addImage:[UIImage imageNamed:@"imageToSend"]];
[tweetSheet setCompletionHandler:completionHandler];
[self presentViewController:tweetSheet animated:YES completion:nil];
//}

}

Upvotes: 1

Oleg Gordiichuk
Oleg Gordiichuk

Reputation: 15512

Hi for sharing information via iOS app it is possible to use native share screen. Using this code you going to share image via different social media.

UIImage *picture = [UIImage imageNamed:@"picture"];   
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[picture] applicationActivities:nil];

Upvotes: 0

Related Questions