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?
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];
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With