The new Apple TV brings the App Store to the big screen at home. With the Facebook SDK for tvOS you can build great social experiences on Apple TV.
With the Facebook SDK for tvOS, you can integrate the following features into your tvOS app:
To make Facebook Login quick and easy, people simply enter a confirmation code displayed on the TV into their smartphone or computer - rather than entering their username and password with the remote.
Download the SDK for tvOSIn the same way that the Apple tvOS SDK inherits iOS frameworks, the Facebook SDK for tvOS inherits from the Facebook SDK for iOS. Here are the available Facebook frameworks for tvOS.
FBSDKLoginKit.framework
This framework is unavailable for tvOS. Use the new FBSDKTVOSKit.framework instead.
FBSDKCoreKit.framework (modified)
The following classes are available:
FBSDKAccessTokenFBSDKAppEventsFBSDKApplicationDelegateFBSDKGraphRequestFBSDKGraphRequestConnectionFBSDKSettingsFBSDKShareKit.framework (modified)
The following classes are available:
FBSDKShareAPIFBSDKShareConstantsFBSDKShareLinkContentFBSDKShareOpenGraphActionFBSDKShareOpenGraphContentFBSDKShareOpenGraphObjectFBSDKSharePhotoFBSDKSharePhotoContentFBSDKShareVideoFBSDKShareVideoContentFBSDKSharingFBSDKSharingContentFBSDKTVOSKit.framework (new)
FBSDKDeviceShareButtonFBSDKDeviceShareViewControllerFBSDKDeviceLoginButtonFBSDKDeviceLoginViewControllerDownload the Facebook SDK for tvOS.
Getting started with the Facebook SDK for tvOS is exactly the same as Getting Started with the Facebook SDK for iOS.
You can import the Facebook frameworks as modules directly (e.g., import FBSDKCoreKit) after linking them to your project.
The SDK for tvOS provides an easy way to implement Facebook Login For Devices.

Login with Facebook is easy with the new TVOSKit.framework. Simply add the FBSDKDeviceLoginButton button to your view.
When a person focuses and selects the button, a modal dialog slides into the view and present a confirmation code. Once someone confirms the code, the button notifies its delegate and the [FBSDKAccessToken currentAccessToken] will be set.
To enable this feature, go to your app settings (https://developers.facebook.com/apps/{YOUR_APP_ID}/settings/advanced/) - Advanced - Client Oauth Settings and turn on Login from Devices:

Example:
#import <FBSDKTVOSKit/FBSDKTVOSKit.h> FBSDKDeviceLoginButton *button = [[FBSDKDeviceLoginButton alloc] initWithFrame:CGRectZero]; button.readPermissions = @[@"email"]; //optional. button.center = self.view.center; [self.view addSubview:button];
If you need to provide specific reauthorization behavior, for example if you are asking for additional permissions, you can directly present the modal dialog by showing an instance of FBSDKDeviceLoginViewController
Example:
FBSDKDeviceLoginViewController *viewController = [[FBSDKDeviceLoginViewController alloc] init]; viewController.publishPermissions = @[@"publish_actions"]; viewController.delegate = self; [self presentViewController:viewController animated:YES completion:NULL];
To log a user out, simply clear the current access token:
[FBSDKAccessToken setCurrentAccessToken:nil];
You can also redirect the user to your app's website after completing the authorization by setting the redirectURL property of the button or view controller. This is especially useful if you have additional account management for the person.
button.redirectURL = ...;
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.
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];
You add rich analytics to your tvOS apps by logging events in the same way as the Facebook SDK for iOS. Login is not required for your app to log events.
Example:
#import <FBSDKCoreKit/FBSDKCoreKit.h> [FBSDKAppEvents activateApp];
You can also access the social graph in the same way as our SDK for iOS, see Using the Graph API, iOS. To do this you need an access token with the right permissions from the person using your app.
Example:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
// If you have user_likes permission granted
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me/likes" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
//TODO: process error or result.
}];For more information on user permissions, see Permissions with Facebook Login.