Overview
DeviceLoginManager implements Facebook’s Device Login flow, which is designed for devices without a standard browser or limited input capabilities, such as tvOS apps.
The flow works as follows:
- Call
start()to request a short user code and a verification URL from Facebook. - The manager calls your delegate’s
deviceLoginManager(_:startedWith:)method with aDeviceLoginCodeInfoobject containing the code and URL. - Present the code to the user and direct them to the URL to complete authentication on another device.
- The manager polls Facebook periodically. When the user completes (or declines) the flow, your delegate’s
deviceLoginManager(_:completedWith:error:)method is called.
FacebookLoginDeclared in:
DeviceLoginManager.swiftObjective-C name:
FBSDKDeviceLoginManager
Initializer
init(permissions:enableSmartLogin:)
The permissions to request, e.g.
["public_profile", "email"].When
true, the manager uses Bonjour to advertise the login code on the local network so nearby devices can complete the flow automatically (Smart Login).Properties
A weak reference to the object receiving login events. Set this before calling
start().The permissions that were passed to the initializer. Read-only.
An optional URL to redirect the user to after login completes. Must be registered in your app settings under Advanced → OAuth Redirect URIs.
Methods
start()
Begins the device login flow. The manager retains itself until the flow finishes or you call cancel().
cancel()
Attempts to cancel the device login flow and releases the internal self-reference.
DeviceLoginManagerDelegate protocol
Implement this protocol in your view controller or coordinator to respond to login events.
Objective-C name: FBSDKDeviceLoginManagerDelegate
deviceLoginManager(_:startedWith:)
Called when the manager has received a device login code from Facebook.
The manager that started the flow.
The code and URL to present to the user. See
DeviceLoginCodeInfo.deviceLoginManager(_:completedWith:error:)
Called when the device login flow finishes, regardless of the outcome.
The manager that completed the flow.
The login result, or
nil if an error occurred. See DeviceLoginManagerResult.An error, or
nil if the flow succeeded or was cancelled.DeviceLoginCodeInfo
Contains the information you need to display to the user at the start of the device login flow.
Objective-C name: FBSDKDeviceLoginCodeInfo
A unique identifier for this login flow instance, used internally for polling.
The short user code to display to the user. The user enters this code at the
verificationURL.The URL where the user completes the flow on another device (e.g.
https://facebook.com/device).The date and time when the code expires.
How frequently (in seconds) the manager polls Facebook for a result. Minimum value is 5 seconds.
DeviceLoginManagerResult
Represents the outcome of the device login flow.
Objective-C name: FBSDKDeviceLoginManagerResult
The access token granted upon successful login.
nil if the login was cancelled or failed.true if the user cancelled the flow or if the device login code expired.