-
public class LoginManager
This class manages login and permissions for Facebook.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
LoginManager.FacebookLoginActivityResultContract
The ActivityResultContract object for login. This contract can be used as the parameter for
registerForActivityResult
.public class
LoginManager.Companion
-
Field Summary
Fields Modifier and Type Field Description private LoginBehavior
loginBehavior
private DefaultAudience
defaultAudience
private String
authType
private LoginTargetApp
loginTargetApp
private Boolean
isFamilyLogin
private Boolean
shouldSkipAccountDeduplication
-
Constructor Summary
Constructors Constructor Description LoginManager()
-
Method Summary
Modifier and Type Method Description final LoginBehavior
getLoginBehavior()
The login behavior. final Unit
setLoginBehavior(LoginBehavior loginBehavior)
final DefaultAudience
getDefaultAudience()
The default audience. final Unit
setDefaultAudience(DefaultAudience defaultAudience)
final String
getAuthType()
The authType final Unit
setAuthType(String authType)
final LoginTargetApp
getLoginTargetApp()
The login target app. final Unit
setLoginTargetApp(LoginTargetApp loginTargetApp)
final Boolean
getIsFamilyLogin()
Determines whether we are using the cross Family of Apps login experience. final Unit
setIsFamilyLogin(Boolean isFamilyLogin)
final Boolean
getShouldSkipAccountDeduplication()
Determines if we should skip deduplicating account during x-FoA login. final Unit
setShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication)
final Unit
resolveError(Activity activity, GraphResponse response)
Starts the login process to resolve the error defined in the response. final Unit
resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. final Unit
resolveError(Fragment fragment, CallbackManager callbackManager, GraphResponse response)
Starts the login process to resolve the error defined in the response. final Unit
resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. final Unit
resolveError(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, GraphResponse response)
Starts the login process to resolve the error defined in the response. final Unit
registerCallback(CallbackManager callbackManager, FacebookCallback<LoginResult> callback)
Registers a login callback to the given callback manager. final Unit
unregisterCallback(CallbackManager callbackManager)
Unregisters a login callback to the given callback manager. Boolean
onActivityResult(Integer resultCode, Intent data, FacebookCallback<LoginResult> callback)
Boolean
onActivityResult(Integer resultCode, Intent data)
final LoginManager
setLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior. final LoginManager
setLoginTargetApp(LoginTargetApp targetApp)
Setter for the login target app. final LoginManager
setDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience. final LoginManager
setAuthType(String authType)
Setter for the authType final LoginManager
setMessengerPageId(String messengerPageId)
Setter for the messengerPageId final LoginManager
setResetMessengerState(Boolean resetMessengerState)
Setter for the resetMessengerState. final LoginManager
setFamilyLogin(Boolean isFamilyLogin)
Setter for whether we are using cross Family of Apps login final LoginManager
setShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication)
Setter for whether we are skipping deduplicating account during x-FoA login. Unit
logOut()
Logs out the user. final Unit
retrieveLoginStatus(Context context, LoginStatusCallback responseCallback)
Retrieves the login status for the user. final Unit
retrieveLoginStatus(Context context, Long toastDurationMs, LoginStatusCallback responseCallback)
Retrieves the login status for the user. final Unit
logInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions. final Unit
logInWithReadPermissions(Fragment fragment, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested read permissions. final Unit
logInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions. final Unit
logInWithReadPermissions(Activity activity, Collection<String> permissions)
Logs the user in with the requested read permissions. final Unit
logInWithReadPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested read permissions. final Unit
logInWithConfiguration(Fragment fragment, LoginConfiguration loginConfig)
Logs the user in with the requested configuration. final Unit
loginWithConfiguration(Activity activity, LoginConfiguration loginConfig)
Logs the user in with the requested configuration. final Unit
reauthorizeDataAccess(Activity activity)
Reauthorize data access final Unit
reauthorizeDataAccess(Fragment fragment)
Reauthorize data access final Unit
logInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions. final Unit
logInWithPublishPermissions(Fragment fragment, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested publish permissions. final Unit
logInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions. final Unit
logInWithPublishPermissions(Activity activity, Collection<String> permissions)
Logs the user in with the requested publish permissions. final Unit
logInWithPublishPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested read permissions. final Unit
logIn(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested permissions. final Unit
logIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. final Unit
logIn(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested permissions. final Unit
logIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. final Unit
logIn(FragmentWrapper fragment, Collection<String> permissions)
Logs the user in with the requested permissions. final Unit
logIn(FragmentWrapper fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. final Unit
logIn(Activity activity, Collection<String> permissions)
Logs the user in with the requested permissions. final Unit
logIn(FragmentWrapper fragment, LoginConfiguration loginConfig)
Logs the user in with the requested login configuration. final Unit
logIn(Activity activity, LoginConfiguration loginConfig)
Logs the user in with the requested configuration. final Unit
logIn(Activity activity, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. final Unit
logIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions. final Unit
logIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested permissions. final LoginManager.FacebookLoginActivityResultContract
createLogInActivityResultContract(CallbackManager callbackManager, String loggerID)
Create the ActivityResultContract object for login. final LoginManager.FacebookLoginActivityResultContract
createLogInActivityResultContract(CallbackManager callbackManager)
Create the ActivityResultContract object for login. final LoginManager.FacebookLoginActivityResultContract
createLogInActivityResultContract()
Create the ActivityResultContract object for login. -
-
Method Detail
-
getLoginBehavior
final LoginBehavior getLoginBehavior()
The login behavior.
-
setLoginBehavior
final Unit setLoginBehavior(LoginBehavior loginBehavior)
-
getDefaultAudience
final DefaultAudience getDefaultAudience()
The default audience.
-
setDefaultAudience
final Unit setDefaultAudience(DefaultAudience defaultAudience)
-
getAuthType
final String getAuthType()
The authType
-
setAuthType
final Unit setAuthType(String authType)
-
getLoginTargetApp
final LoginTargetApp getLoginTargetApp()
The login target app.
-
setLoginTargetApp
final Unit setLoginTargetApp(LoginTargetApp loginTargetApp)
-
getIsFamilyLogin
final Boolean getIsFamilyLogin()
Determines whether we are using the cross Family of Apps login experience. True if using cross Family of Apps login
-
setIsFamilyLogin
final Unit setIsFamilyLogin(Boolean isFamilyLogin)
-
getShouldSkipAccountDeduplication
final Boolean getShouldSkipAccountDeduplication()
Determines if we should skip deduplicating account during x-FoA login. True if Account deduplication is opted out in Family of Apps login
-
setShouldSkipAccountDeduplication
final Unit setShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication)
-
resolveError
final Unit resolveError(Activity activity, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks will be called on completion.
- Parameters:
activity
- The activity which is starting the login process.response
- The response that has the error.
-
resolveError
@Deprecated(message = ) final Unit resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks will be called on completion.
This method is deprecated and it's better to use the method with a CallbackManager as the second parameter. The new method with the CallbackManager as a parameter will use AndroidX activity 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
final Unit resolveError(Fragment fragment, CallbackManager callbackManager, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks 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
final Unit resolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks 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
final Unit resolveError(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks 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
final Unit 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
final Unit unregisterCallback(CallbackManager callbackManager)
Unregisters a login callback to the given callback manager.
- Parameters:
callbackManager
- The callback manager that will encapsulate the callback.
-
onActivityResult
@JvmOverloads() Boolean onActivityResult(Integer resultCode, Intent data, FacebookCallback<LoginResult> callback)
-
onActivityResult
@JvmOverloads() Boolean onActivityResult(Integer resultCode, Intent data)
-
setLoginBehavior
final LoginManager setLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior.
- Parameters:
loginBehavior
- The login behavior.
-
setLoginTargetApp
final LoginManager setLoginTargetApp(LoginTargetApp targetApp)
Setter for the login target app.
- Parameters:
targetApp
- The login target app.
-
setDefaultAudience
final LoginManager setDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience.
- Parameters:
defaultAudience
- The default audience.
-
setAuthType
final LoginManager setAuthType(String authType)
Setter for the authType
- Parameters:
authType
- The authType
-
setMessengerPageId
final LoginManager setMessengerPageId(String messengerPageId)
Setter for the messengerPageId
- Parameters:
messengerPageId
- The messengerPageId
-
setResetMessengerState
final LoginManager setResetMessengerState(Boolean resetMessengerState)
Setter for the resetMessengerState. For developers of the app only.
- Parameters:
resetMessengerState
- Whether to enable resetMessengerState
-
setFamilyLogin
final 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
-
setShouldSkipAccountDeduplication
final 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 deduplication experience in Family of Apps login
-
retrieveLoginStatus
final Unit retrieveLoginStatus(Context context, LoginStatusCallback responseCallback)
Retrieves the login status for the user. This will return an access token for the app if a user is logged into the Facebook for Android app on the same device and that user had previously logged into the app. If an access token was retrieved then a toast will be shown telling the user that they have been logged in.
- Parameters:
context
- An Android contextresponseCallback
- The callback to be called when the request completes
-
retrieveLoginStatus
final Unit 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 user is logged into the Facebook for Android app on the same device and that user had previously logged into the app. If an access token was retrieved then a toast will be shown telling the user 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(message = ) final Unit 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 the second parameter. The new method with the CallbackManager as a parameter will use AndroidX activity 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
final Unit logInWithReadPermissions(Fragment fragment, CallbackManager callbackManager, 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
final Unit 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
final Unit 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
final Unit logInWithReadPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, 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
final Unit logInWithConfiguration(Fragment fragment, 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
final Unit loginWithConfiguration(Activity activity, 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
final Unit reauthorizeDataAccess(Activity activity)
Reauthorize data access
- Parameters:
activity
- The activity which is starting the reauthorization process.
-
reauthorizeDataAccess
final Unit reauthorizeDataAccess(Fragment fragment)
Reauthorize data access
- Parameters:
fragment
- The android.support.v4.app.Fragment starting the reauthorization process.
-
logInWithPublishPermissions
@Deprecated(message = ) final Unit 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 the second parameter. The new method with the CallbackManager as a parameter will use AndroidX activity 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
final Unit logInWithPublishPermissions(Fragment fragment, CallbackManager callbackManager, 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
final Unit 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
final Unit 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
final Unit logInWithPublishPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, 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
final Unit 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
final Unit 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
final Unit 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
final Unit 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
final Unit 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
final Unit 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
final Unit 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
final Unit logIn(FragmentWrapper fragment, 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
final Unit logIn(Activity activity, 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
final Unit 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
final Unit logIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, 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
final Unit logIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, 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.
-
createLogInActivityResultContract
@JvmOverloads() final LoginManager.FacebookLoginActivityResultContract createLogInActivityResultContract(CallbackManager callbackManager, String loggerID)
Create the ActivityResultContract object for login. This contract can be used as the parameter for
registerForActivityResult
.For example, in an AndroidX activity/fragment:
// onCreate val launcher = registerForActivityResult( loginManager.createLogInActivityResultContract(callbackManager)) {...} // when user click the login button launcher.launch(permissions)
In Jetpack Compose, we can use
rememberLauncherForActivityResult( contract = loginManager.createLogInActivityResultContract(callbackManager, null), onResult = {...} )
to create the launcher
- Parameters:
callbackManager
- the callback manager to register login callbacks.loggerID
- the logger Id for the login request.
-
createLogInActivityResultContract
@JvmOverloads() final LoginManager.FacebookLoginActivityResultContract createLogInActivityResultContract(CallbackManager callbackManager)
Create the ActivityResultContract object for login. This contract can be used as the parameter for
registerForActivityResult
.For example, in an AndroidX activity/fragment:
// onCreate val launcher = registerForActivityResult( loginManager.createLogInActivityResultContract(callbackManager)) {...} // when user click the login button launcher.launch(permissions)
In Jetpack Compose, we can use
rememberLauncherForActivityResult( contract = loginManager.createLogInActivityResultContract(callbackManager, null), onResult = {...} )
to create the launcher
- Parameters:
callbackManager
- the callback manager to register login callbacks.
-
createLogInActivityResultContract
@JvmOverloads() final LoginManager.FacebookLoginActivityResultContract createLogInActivityResultContract()
Create the ActivityResultContract object for login. This contract can be used as the parameter for
registerForActivityResult
.For example, in an AndroidX activity/fragment:
// onCreate val launcher = registerForActivityResult( loginManager.createLogInActivityResultContract(callbackManager)) {...} // when user click the login button launcher.launch(permissions)
In Jetpack Compose, we can use
rememberLauncherForActivityResult( contract = loginManager.createLogInActivityResultContract(callbackManager, null), onResult = {...} )
to create the launcher
-
-
-
-