Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS SLComposeViewController - url not displaying for twitter post

I am using the SLComposeViewController to post to twitter and Facebook. I have the same code for both twitter & facebook but the URL is not showing up in the twitter post. How do I fix this?

enter image description here

Twitter code -

socialController = [SLComposeViewController
    composeViewControllerForServiceType:SLServiceTypeTwitter];
[socialController setInitialText:@"Testing: This is the app link!"];
[socialController addImage:[UIImage imageNamed:@"image.jpg"]];
[socialController addURL:[NSURL URLWithString:@"http://www.google.com"]];
[self presentViewController:socialController animated:YES completion:nil];

Facebook code -

socialController = [SLComposeViewController
    composeViewControllerForServiceType:SLServiceTypeFacebook];
[socialController setInitialText:@"Testing: This is the app link!"];
[socialController addImage:[UIImage imageNamed:@"image.jpg"]];
[socialController addURL:[NSURL URLWithString:@"http://www.google.com"]];
[self presentViewController:socialController animated:YES completion:nil];
like image 280
rohan_vg Avatar asked Sep 11 '13 14:09

rohan_vg


2 Answers

SLComposeViewController shows the URL as an attachment on tweet compose view. When it is sent, URL will be appended to the end of the post. You may even add multiple URLs, they will be still shown as attachments. So this is the way it should be, there is nothing to fix.

like image 133
mkubilayk Avatar answered Oct 28 '22 22:10

mkubilayk


  • I suggest you actually send the tweet, and check on your Twitter account wether it is really missing the URL or not (it may just be working as expected)

  • This is apparently not what's causing your troubles, but beware of your message length: I have found out that when the text message is too long, the Twitter API silently skips the steps where it should include the shortened URLs for the image and the URL. According to this answer, your text should not exceed 113 characters if you use addURL twice.

like image 41
Sébastien Avatar answered Oct 28 '22 23:10

Sébastien