3

I have a NSString which one I use for share on Facebook & Twitter. My requirement is that text will be a link after share on Facebook. On Facebook when user click on that text, then direct go to that link.

My code is like below:

NSInteger Score = [[NSUserDefaults standardUserDefaults] integerForKey:@"K_ScoreVal"];

SLComposeViewController *Facebooksheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[Facebooksheet setInitialText:[NSString stringWithFormat:@"I just completed level 1.1 and score is %d points.",Score]];
[[CCDirector sharedDirector] presentViewController:Facebooksheet animated:YES completion:nil];

I just completed level 1.1 and score is 455 points. This is my text, which one I share on Facebook. But when user click on this text, then direct go to a link. Meanwhile I want to make this text as a hyperlink.

Please suggest me.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Soumya Ranjan
  • 4,817
  • 2
  • 26
  • 51
  • this will help you on the clickable part http://stackoverflow.com/a/3169834/1042240 – Ahmed Z. May 21 '14 at 09:41
  • no i don't want like this. I want when game is over that time automatic the facebook share page is coming with this text. and user can share on facebook. But when i click this text on facebook then it'll be go to link. So how can i implement this hyperlink on text before sharing on Facebook – Soumya Ranjan May 21 '14 at 09:47
  • You can add url to `SLComposeViewController` using `addURL`. Is that you want? – Anil Varghese May 21 '14 at 09:50
  • yeah i can add url, but that url is showing in Facebook. But i want that text "I just completed level 1.1 and score is 455 points." is showing on facebook and when i click on this text, then it'll go to the url – Soumya Ranjan May 21 '14 at 09:52

2 Answers2

0

What you really want to use is the OpenGraph API for games. Have a look at the introduction docs at https://developers.facebook.com/docs/games/opengraph/

If you go down this road, you can use the

Tobi
  • 31,405
  • 8
  • 58
  • 90
0

Have you tried using Attributed Strings?

NSString *shareString = [[NSAttributedString alloc] initWithString:@"I just completed level 1.1 and score is 455 points." attributes:@{NSLinkAttributeName: @"http://yourlink.com"}];
Calle Bergström
  • 480
  • 4
  • 12
  • if i take NSAttributedString *shareString instead of NSString *shareString, then when i add this NSAttributedString like this [Facebooksheet setInitialText:[NSString stringWithFormat:@"%@",shareString]]; its showing text with this link also – Soumya Ranjan May 21 '14 at 12:45
  • ya thats ok , but my question is not like that. Please read my question. – Soumya Ranjan May 21 '14 at 13:02