Prompts the user to authorize your application using the Login Dialog appropriate to the platform. If the user is already logged in and has authorized your application, checks whether all permissions in the permissions
parameter have been granted, and if not, prompts the user for any that are newly requested.
In the Unity Editor, a stub function is called, which will prompt you to provide an access token from the Access Token Tool. Please note that this token will not necessarily contain the permissions you specified in FB.Login. To change this token's permissions, please use the Graph API Explorer.
public static void LogInWithReadPermissions( IEnumerable<string> permissions = null, FacebookDelegate<ILoginResult> callback = null )
Name | Type | Description | Default |
---|---|---|---|
permissions | IEnumerable<string> | A list of Facebook permissions requested from the user | empty list (basic authorization) |
callback | FacebookDelegate
<ILoginResult> | A delegate that will be called with the result of the Login Dialog. A platform-independent representation is available from the properties FB.UserId , AccessToken , and via the boolean FB.IsLoggedIn . | null |
FB.LogInWithReadPermissions ( new List<string>(){"public_profile", "email"}, AuthCallback );
Check out SDK Examples for a more complete sample usage of FB.LogInWithReadPermissions
.
You should check which permissions the user has actually granted your app - you may not have all of the permissions you asked for in the permissions
parameter, as the user may have authorized the app for some but not others. Users can also revoke permissions via their Privacy settings, outside the app. When designing, take the dynamic nature of permissions into account. To find out which permissions you have at any given time, you can read the /user/permissions
Graph API endpoint, or you can use the AccessToken convenience class like below.
using Facebook.Unity; foreach(string perm in AccessToken.CurrentAccessToken.Permissions) { // log each granted permission Debug.Log(perm); }
Please use the Facebook Login Checklist to make sure you're providing users with a consistent, pleasant experience. Also, see our Login documentation to learn how authentication and authorization work in the broader context of Facebook.
Generally, you will get the best uptake of Facebook login among your users if you make the login control a prominent element on the first screen they should interact with. You may also wish to incentivize users to log in or upsell them to grant key permissions; for example, we find that "email"
is important for communicating with users having trouble accessing your game, but some users are reluctant to grant it. Building a reputation for responsible use of the permissions you ask for, and offering a token in-game reward, can help.