-
public class LoginManager
This class manages login and permissions for Facebook.
-
-
Field Summary
Fields Modifier and Type Field Description private static volatile LoginManager
instance
private LoginBehavior
loginBehavior
private DefaultAudience
defaultAudience
private String
authType
private String
messengerPageId
private boolean
resetMessengerState
private boolean
isFamilyLogin
private boolean
shouldSkipAccountDeduplication
-
Method Summary
Modifier and Type Method Description static LoginManager
getInstance()
Getter for the login manager. LoginBehavior
getLoginBehavior()
Getter for the login behavior. LoginManager
setLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior. DefaultAudience
getDefaultAudience()
Getter for the default audience. LoginManager
setDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience. String
getAuthType()
Getter for the authType LoginManager
setAuthType(String authType)
Setter for the authType LoginManager
setMessengerPageId(@Nullable() String messengerPageId)
Setter for the messengerPageId LoginManager
setResetMessengerState(boolean resetMessengerState)
Setter for the resetMessengerState. boolean
isFamilyLogin()
Determines whether we are using the cross Family of Apps login experience boolean
getShouldSkipAccountDeduplication()
Determines if we should skip deduplicating account during x-FoA login. LoginManager
setShouldSkipAccountDeduplication(boolean shouldSkipAccountDeduplication)
Setter for whether we are skipping deduplicating account during x-FoA login. void
resolveError(Activity activity, GraphResponse response)
Starts the login process to resolve the error defined in the response. void
resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. void
resolveError(@NonNull() Fragment fragment, @NonNull() CallbackManager callbackManager, @NonNull() GraphResponse response)
Starts the login process to resolve the error defined in the response. void
resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. void
resolveError(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() GraphResponse response)
Starts the login process to resolve the error defined in the response. void
registerCallback(CallbackManager callbackManager, FacebookCallback<LoginResult> callback)
Registers a login callback to the given callback manager. void
unregisterCallback(CallbackManager callbackManager)
Unregisters a login callback to the given callback manager. LoginTargetApp
getLoginTargetApp()
Getter for the login target app. LoginManager
setLoginTargetApp(LoginTargetApp targetApp)
Setter for the login target app. LoginManager
setFamilyLogin(boolean isFamilyLogin)
Setter for whether we are using cross Family of Apps login void
logOut()
Logs out the user. void
retrieveLoginStatus(Context context, LoginStatusCallback responseCallback)
Retrieves the login status for the user. void
retrieveLoginStatus(Context context, long toastDurationMs, LoginStatusCallback responseCallback)
Retrieves the login status for the user. void
logInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions. void
logInWithReadPermissions(@NonNull() Fragment fragment, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested read permissions. void
logInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions. void
logInWithReadPermissions(Activity activity, Collection<String> permissions)
Logs the user in with the requested read permissions. void
logInWithReadPermissions(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested read permissions. void
logInWithConfiguration(Fragment fragment, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested configuration. void
loginWithConfiguration(Activity activity, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested configuration. void
reauthorizeDataAccess(Activity activity)
Reauthorize data access void
reauthorizeDataAccess(Fragment fragment)
Reauthorize data access void
logInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions. void
logInWithPublishPermissions(@NonNull() Fragment fragment, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested publish permissions. void
logInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions. void
logInWithPublishPermissions(Activity activity, Collection<String> permissions)
Logs the user in with the requested publish permissions. void
logInWithPublishPermissions(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested read permissions. void
logIn(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested permissions. void
logIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. void
logIn(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested permissions. void
logIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. void
logIn(FragmentWrapper fragment, Collection<String> permissions)
Logs the user in with the requested permissions. void
logIn(FragmentWrapper fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. void
logIn(Activity activity, Collection<String> permissions)
Logs the user in with the requested permissions. void
logIn(FragmentWrapper fragment, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested login configuration. void
logIn(Activity activity, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested configuration. void
logIn(Activity activity, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. void
logIn(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. void
logIn(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested permissions. -
-
Method Detail
-
getInstance
static LoginManager getInstance()
Getter for the login manager.
-
getLoginBehavior
LoginBehavior getLoginBehavior()
Getter for the login behavior.
-
setLoginBehavior
LoginManager setLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior.
- Parameters:
loginBehavior
- The login behavior.
-
getDefaultAudience
DefaultAudience getDefaultAudience()
Getter for the default audience.
-
setDefaultAudience
LoginManager setDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience.
- Parameters:
defaultAudience
- The default audience.
-
getAuthType
String getAuthType()
Getter for the authType
-
setAuthType
LoginManager setAuthType(String authType)
Setter for the authType
- Parameters:
authType
- The authType
-
setMessengerPageId
LoginManager setMessengerPageId(@Nullable() String messengerPageId)
Setter for the messengerPageId
- Parameters:
messengerPageId
- The messengerPageId
-
setResetMessengerState
LoginManager setResetMessengerState(boolean resetMessengerState)
Setter for the resetMessengerState. For developers of the app only.
- Parameters:
resetMessengerState
- Whether to enable resetMessengerState
-
isFamilyLogin
boolean isFamilyLogin()
Determines whether we are using the cross Family of Apps login experience
-
getShouldSkipAccountDeduplication
boolean getShouldSkipAccountDeduplication()
Determines if we should skip deduplicating account during x-FoA login.
-
setShouldSkipAccountDeduplication
LoginManager setShouldSkipAccountDeduplication(boolean shouldSkipAccountDeduplication)
Setter for whether we are skipping deduplicating account during x-FoA login.
- Parameters:
shouldSkipAccountDeduplication
- Whether we want to opt out account deduplicationexperience in Family of Apps login
-
resolveError
void resolveError(Activity activity, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered logincallbacks will be called on completion.
- Parameters:
activity
- The activity which is starting the login process.response
- The response that has the error.
-
resolveError
@Deprecated() void resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered logincallbacks will be called on completion.
This method is deprecated and it's better to use the method with a CallbackManager as thesecond parameter. The new method with the CallbackManager as a parameter will use AndroidXactivity result APIs so you won't need to override onActivityResult method on the fragment.
- Parameters:
fragment
- The fragment which is starting the login process.response
- The response that has the error.
-
resolveError
void resolveError(@NonNull() Fragment fragment, @NonNull() CallbackManager callbackManager, @NonNull() GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered logincallbacks will be called on completion.
- Parameters:
fragment
- The fragment which is starting the login process.callbackManager
- The callback manager which is used to register callbacks.response
- The response that has the error.
-
resolveError
void resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered logincallbacks will be called on completion.
- Parameters:
fragment
- The android.app.Fragment which is starting the login process.response
- The response that has the error.
-
resolveError
void resolveError(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered logincallbacks will be called on completion.
- Parameters:
activityResultRegistryOwner
- The activity result register owner.callbackManager
- The callback manager from Facebook SDK.response
- The response that has the error.
-
registerCallback
void registerCallback(CallbackManager callbackManager, FacebookCallback<LoginResult> callback)
Registers a login callback to the given callback manager.
- Parameters:
callbackManager
- The callback manager that will encapsulate the callback.callback
- The login callback that will be called on login completion.
-
unregisterCallback
void unregisterCallback(CallbackManager callbackManager)
Unregisters a login callback to the given callback manager.
- Parameters:
callbackManager
- The callback manager that will encapsulate the callback.
-
getLoginTargetApp
LoginTargetApp getLoginTargetApp()
Getter for the login target app.
-
setLoginTargetApp
LoginManager setLoginTargetApp(LoginTargetApp targetApp)
Setter for the login target app.
- Parameters:
targetApp
- The login target app.
-
setFamilyLogin
LoginManager setFamilyLogin(boolean isFamilyLogin)
Setter for whether we are using cross Family of Apps login
- Parameters:
isFamilyLogin
- Whether we are using cross Family of Apps login
-
logOut
void logOut()
Logs out the user.
-
retrieveLoginStatus
void retrieveLoginStatus(Context context, LoginStatusCallback responseCallback)
Retrieves the login status for the user. This will return an access token for the app if a useris logged into the Facebook for Android app on the same device and that user had previouslylogged into the app. If an access token was retrieved then a toast will be shown telling theuser that they have been logged in.
- Parameters:
context
- An Android contextresponseCallback
- The callback to be called when the request completes
-
retrieveLoginStatus
void retrieveLoginStatus(Context context, long toastDurationMs, LoginStatusCallback responseCallback)
Retrieves the login status for the user. This will return an access token for the app if a useris logged into the Facebook for Android app on the same device and that user had previouslylogged into the app. If an access token was retrieved then a toast will be shown telling theuser that they have been logged in.
- Parameters:
context
- An Android contexttoastDurationMs
- The duration to show the success toast in millisecondsresponseCallback
- The callback to be called when the request completes
-
logInWithReadPermissions
@Deprecated() void logInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions.
This method is deprecated and it's better to use the method with a CallbackManager as thesecond parameter. The new method with the CallbackManager as a parameter will use AndroidXactivity result APIs so you won't need to override onActivityResult method on the fragment.
- Parameters:
fragment
- The androidx.fragment.Fragment which is starting the login process.permissions
- The requested permissions.
-
logInWithReadPermissions
void logInWithReadPermissions(@NonNull() Fragment fragment, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested read permissions.
- Parameters:
fragment
- The androidx.fragment.Fragment which is starting the login process.callbackManager
- The callback manager which is used to register callbacks.permissions
- The requested permissions.
-
logInWithReadPermissions
void logInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions.
- Parameters:
fragment
- The android.app.Fragment which is starting the login process.permissions
- The requested permissions.
-
logInWithReadPermissions
void logInWithReadPermissions(Activity activity, Collection<String> permissions)
Logs the user in with the requested read permissions.
- Parameters:
activity
- The activity which is starting the login process.permissions
- The requested permissions.
-
logInWithReadPermissions
void logInWithReadPermissions(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested read permissions.
- Parameters:
activityResultRegistryOwner
- The activity result register owner.callbackManager
- The callback manager from Facebook SDK.permissions
- The requested permissions.
-
logInWithConfiguration
void logInWithConfiguration(Fragment fragment, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested configuration.
- Parameters:
fragment
- The android.support.v4.app.Fragment which is starting the login process.loginConfig
- The login configuration
-
loginWithConfiguration
void loginWithConfiguration(Activity activity, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested configuration.
- Parameters:
activity
- The activity which is starting the login process.loginConfig
- The login configuration
-
reauthorizeDataAccess
void reauthorizeDataAccess(Activity activity)
Reauthorize data access
- Parameters:
activity
- The activity which is starting the reauthorization process.
-
reauthorizeDataAccess
void reauthorizeDataAccess(Fragment fragment)
Reauthorize data access
- Parameters:
fragment
- The android.support.v4.app.Fragment starting the reauthorization process.
-
logInWithPublishPermissions
@Deprecated() void logInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions.
This method is deprecated and it's better to use the method with a CallbackManager as thesecond parameter. The new method with the CallbackManager as a parameter will use AndroidXactivity result APIs so you won't need to override onActivityResult method on the fragment.
- Parameters:
fragment
- The androidx.fragment.Fragment which is starting the login process.permissions
- The requested permissions.
-
logInWithPublishPermissions
void logInWithPublishPermissions(@NonNull() Fragment fragment, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested publish permissions.
- Parameters:
fragment
- The androidx.fragment.Fragment which is starting the login process.callbackManager
- The callback manager which is used to register callbacks.permissions
- The requested permissions.
-
logInWithPublishPermissions
void logInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions.
- Parameters:
fragment
- The android.app.Fragment which is starting the login process.permissions
- The requested permissions.
-
logInWithPublishPermissions
void logInWithPublishPermissions(Activity activity, Collection<String> permissions)
Logs the user in with the requested publish permissions.
- Parameters:
activity
- The activity which is starting the login process.permissions
- The requested permissions.
-
logInWithPublishPermissions
void logInWithPublishPermissions(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested read permissions.
- Parameters:
activityResultRegistryOwner
- The activity result register owner.callbackManager
- The callback manager from Facebook SDK.permissions
- The requested permissions.
-
logIn
void logIn(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested permissions.
- Parameters:
fragment
- The android.support.v4.app.Fragment which is starting the login process.permissions
- The requested permissions.
-
logIn
void logIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
- Parameters:
fragment
- The android.support.v4.app.Fragment which is starting the login process.permissions
- The requested permissions.loggerID
- Override the default logger ID for the request
-
logIn
void logIn(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested permissions.
- Parameters:
fragment
- The android.app.Fragment which is starting the login process.permissions
- The requested permissions.
-
logIn
void logIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
- Parameters:
fragment
- The android.app.Fragment which is starting the login process.permissions
- The requested permissions.loggerID
- Override the default logger ID for the request
-
logIn
void logIn(FragmentWrapper fragment, Collection<String> permissions)
Logs the user in with the requested permissions.
- Parameters:
fragment
- The fragment which is starting the login process.permissions
- The requested permissions.
-
logIn
void logIn(FragmentWrapper fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
- Parameters:
fragment
- The fragment which is starting the login process.permissions
- The requested permissions.loggerID
- Override the default logger ID for the request
-
logIn
void logIn(Activity activity, Collection<String> permissions)
Logs the user in with the requested permissions.
- Parameters:
activity
- The activity which is starting the login process.permissions
- The requested permissions.
-
logIn
void logIn(FragmentWrapper fragment, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested login configuration.
- Parameters:
fragment
- The fragment which is starting the login process.loginConfig
- The login config of the request
-
logIn
void logIn(Activity activity, @NonNull() LoginConfiguration loginConfig)
Logs the user in with the requested configuration.
- Parameters:
activity
- The activity which is starting the login process.loginConfig
- The login config of the request
-
logIn
void logIn(Activity activity, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
- Parameters:
activity
- The activity which is starting the login process.permissions
- The requested permissions.loggerID
- Override the default logger ID for the request
-
logIn
void logIn(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
- Parameters:
activityResultRegistryOwner
- The activity result register owner.callbackManager
- The callback manager from Facebook SDK.permissions
- The requested permissions.loggerID
- Override the default logger ID for the request
-
logIn
void logIn(@NonNull() ActivityResultRegistryOwner activityResultRegistryOwner, @NonNull() CallbackManager callbackManager, @NonNull() Collection<String> permissions)
Logs the user in with the requested permissions.
- Parameters:
activityResultRegistryOwner
- The activity result register owner.callbackManager
- The callback manager from Facebook SDK.permissions
- The requested permissions.
-
-
-
-