# Modules.Facebook.LoginButton

A Facebook Login Button.

Availability
3.1.0
3.1.0

# Overview

Use the Modules.Facebook.createLoginButton method to create a Login button. If you want to request user permissions when the user logs in, set either the Modules.Facebook.LoginButton.readPermissions or Modules.Facebook.LoginButton.publishPermissions property, but do not set both. If both properties are set, the application will throw an exception. If neither property is set, by default, only the user_profile permission is requested.

The Login button does not require a click event handler or any listeners. Click events on the button are automatically handled by the Facebook module.

The button changes its label to reflect the current state of the Facebook session. For example, if the user is already logged in, the button will show "Logout".

# Android Platform Notes

In Android, the button's width will change depending on the current state it is in. When logged out, it will show "Log in with Facebook" and its width will match the length of the text. When logged in, it will show "Log out" and its width will match the length of the text.

# iOS Platform Notes

In iOS, the width and height of the button can be changed using the width and height property. The Facebook SDK 4.19.0 and later (used in Ti.Facebook 5.4.0 and later) provides an updated Login button. The title now is "Continue with Facebook" instead of "Login with Facebook" and the recommended height is 28px. Please always specify a height for best results.

# Properties

# audience

Availability
4.0.0
4.0.0
audience :Number

Default audience to use for Facebook posts if publish permissions are requested.

Default: Modules.Facebook.AUDIENCE_FRIENDS


# loginTracking

Availability
10.0.0
loginTracking :Number

Gets or sets the desired tracking preference to use for login attempts.

Default: Modules.Facebook.LOGIN_TRACKING_ENABLED


# nonce

Availability
10.0.0
nonce :String

Gets or sets an optional nonce to use for login attempts.

A valid nonce must be a non-empty string without whitespace. An invalid nonce will not be set. Instead, default unique nonceswill be used for login attempts.


# publishPermissions

Availability
4.0.0
4.0.0
publishPermissions :Array<String>

Requested write permissions.

For a complete list of permissions, see the official Facebook Permissions Reference.

Sets the permissions to use when the session is opened. The permissions here should only be write permissions. If any read permissions are included, the login attempt by the user will fail. The LoginButton can only be associated with either read permissions or publish permissions, but not both. Using both the readPermissions and publishPermissions property on the same instance of LoginButton will result in an exception being thrown.

Set this property before the session is open. If this property is set after the session is opened, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

Since the session can be automatically opened when the LoginButton is constructed, it is important to always pass in a consistent set of permissions to this property, or manage the setting of permissions outside of the LoginButton class altogether (by managing the session explicitly).


# readPermissions

Availability
4.0.0
4.0.0
readPermissions :Array<String>

Requested read permissions.

For a complete list of permissions, see the official Facebook Permissions Reference.

Sets the permissions to use when the session is opened. The permissions here can only be read permissions. If any publish permissions are included, the login attempt by the user will fail. The LoginButton can only be associated with either read permissions or publish permissions, but not both. Using both the readPermissions and publishPermissions property on the same instance of LoginButton will result in an exception being thrown.

Set this property before the session is open. If this property is set after the session is opened, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

Since the session can be automatically opened when the LoginButton is constructed, it is important to always pass in a consistent set of permissions to this property, or manage the setting of permissions outside of the LoginButton class altogether (by managing the session explicitly).


# tooltipBehavior

Availability
6.1.0
6.1.0
tooltipBehavior :Number

Gets or sets the desired tooltip behavior.

Default: Modules.Facebook.LOGIN_BUTTON_TOOLTIP_BEHAVIOR_AUTOMATIC


# tooltipColorStyle

Availability
6.1.0
6.1.0
tooltipColorStyle :Number

Gets or sets the desired tooltip color style.

Default: Modules.Facebook.LOGIN_BUTTON_TOOLTIP_STYLE_FRIENDLY_BLUE