iOS SocialFramework API

iOS SocialFramework

iOS has social prompt in SDK. Facebook, Twitter, etc…
If you want to use them, you need to add Social.framework
SLComposeViewController is social ViewController.
This class extends UIViewController.

Basically, post style is decided by Service.
Twitter has twitter card which shows special URL contents.

Sample

We can set some items title, image, URL
SLComposeViewController is UIViewController, so you can use it as UIViewController.
presentViewController method opens

- (void)openFacebook {
   SLComposeViewController *viewcontroller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    [viewcontroller setInitialText:@"Facebook wah!"];  // title
    [viewcontroller addImage:[UIImage imageNamed:@"facebook"]];
    [viewcontroller addURL:[NSURL URLWithString:@"http://atmarkplant.com"]];
    [self presentViewController:viewcontroller animated:YES completion:nil];
}

This codes are in UIViewController.
SLServiceTypeFacebook is type. If you change SLServiceTypeTwitter, can switch Twitter.


Post

Post Items

  • Text
  • Image
  • URL

Basically, post style is decided by Service. We cannot manage post style from SDK.
And, we can post above items. This can be managed.

Twitter

Post Appearance
Text : Twitter text
Image : Twitter image
URL : URL (If this URL has Twitter card, Twitter card is shown)

If there are 2 URL in post, the latter is prior.

Facebook

Text : Facebook text
Image : Image
URL : Special URL box with image

※ 2015/06 Facebook changes rules to post from API.
They prohibit to change Text of post. “User should decide post contents” Please check Platform Policy 2.3 Example and Explanation