6

I am using UIActivityViewController for share button.It's showing text and url when I am selecting mail option from list but it's showing only text not url when I am selecting Facebook or Twitter.I searched a lot but not getting solution for my issue.I got one more solution to add "http" in url but is this possible without adding http in url. My code is -

 NSArray *activityItems;
NSString *str;
NSString *noteStr;
str = [NSString stringWithFormat:@"com.boxscoregames.squares://square?%@",squareID];
noteStr = @"You have been invited to join the Square game, please follow the link below on your iPhone.";
NSURL *url = [NSURL URLWithString:str];

// str =[NSString  stringWithFormat:@"<html><a href=\"%@\">%@</a></html>" ,str,str];
activityItems = @[noteStr,url];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
Chaaruu Jadhav
  • 474
  • 4
  • 22

1 Answers1

6

I believe the link is indeed not being shown. But, when you post it, the link will be added to your Facebook/twitter post.

You could of course just also add the link to the text.

NSString *link = [NSString stringWithFormat:@"com.boxscoregames.squares://square?%@",squareID];
NSString *noteStr = [NSString stringWithFormat:@"You have been invited to join the Square game, please follow the link below on your iPhone. %@", link];

NSURL *url = [NSURL URLWithString:link];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[noteStr, url] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
Maarten
  • 351
  • 1
  • 13
  • Thank you for reply..yes, it's working on phone and showing only when i am checking on phone. – Chaaruu Jadhav Dec 17 '14 at 10:57
  • But I want to pass both string as a string and url to redirect on my app. – Chaaruu Jadhav Dec 17 '14 at 12:31
  • The code above will show both the 'note' and the 'link url'. And it will add the link to your post – Maarten Dec 17 '14 at 12:34
  • Now again my url is changed.No my code is - str = [NSString stringWithFormat:@"sportssquares://square?%@",squareID]; noteStr = @"You have been invited to join the Square game, please follow the link below on your iPhone."; NSURL *url = [NSURL URLWithString:str]; activityItems = @[noteStr,url]; and it is giving me an error of "Cannot post to facebook - connection to facebook failed" – Chaaruu Jadhav Dec 19 '14 at 12:20