Sharing for tvOS

Similar to Facebook Login For Devices the SDK for tvOS also supports Sharing For Devices. This provides an easy way for your app to share content without requiring Facebook Login.

You can simply add the FBSDKDeviceShareButton to your view and set the content to share. Example:

#import <FBSDKTVOSKit/FBSDKTVOSKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>

FBSDKDeviceShareButton *button = [[FBSDKDeviceShareButton alloc] initWithFrame:CGRectZero];
FBSDKShareLinkContent *linkContent = [[FBSDKShareLinkContent alloc] init];
linkContent.contentURL = [NSURL URLWithString:@"http://developers.facebook.com/docs/tvos"];
button.shareContent = linkContent;
button.center = self.view.center;
[self.view addSubview:button];

Or you can programmatically invoke the dialog by presenting the FBSDKDeviceShareViewController manually: Example:

FBSDKShareLinkContent *linkContent = [[FBSDKShareLinkContent alloc] init];
linkContent.contentURL = [NSURL URLWithString:@"http://developers.facebook.com/docs/tvos"];
FBSDKDeviceShareViewController *viewController = [[FBSDKDeviceShareViewController alloc] initWithShareContent:linkContent];
[self presentViewController:viewController animated:YES completion:NULL];

You can also share Open Graph content by setting shareContent to an instance of FBSDKShareOpenGraphContent.

Note that unlike Login, there is no delegate or callback so you cannot confirm if the person actually posted to Facebook.

API Sharing

Your app can also share content through the FBSDKShareAPI class with an authorized access token. To create shared content, follow the same approach used for SDK for iOS. See the section on Custom Interfaces in the Sharing documentation. The sharing dialogs are not available on tvOS.

Example:

#import <FBSDKShareKit/FBSDKShareKit.h>


FBSDKShareLinkContent *linkContent = [[FBSDKShareLinkContent alloc] init];
linkContent.contentURL = [NSURL URLWithString:@"http://developers.facebook.com/docs/tvos"];
[FBSDKShareAPI shareWithContent:linkContent delegate:self];