Failed to share url on Facebook and Twitter using UIActivityViewController in iOS 7.1

I use the UIActivityViewController for the share.It button shows the text and URL when I select the mail option from the list, but it only shows the text, not the URL when I select Facebook or Twitter. I searched a lot, but did not get a solution for my problem. I got another solution to add "http" to the url, but this is possible without adding http to the 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]; 
+6
source share
1 answer

I believe the link is really not shown. But, when you post it, the link will be added to your post on Facebook / Twitter.

Of course, you can just add a 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]; 
+6
source

Source: https://habr.com/ru/post/979772/


All Articles