public class FacebookConnect

  1. Object
  2. Login
  3. FacebookConnect
Invokes the native bundled facebook SDK to login/logout of facebook, notice that in order for this to work server build arguments must indicate that you are using the facebook sdk! To accomplish this just define: facebook.appId=YourAppId in your build arguments. In order to obtain the app ID you need to create a native Android/iOS application and generate the right app id.

Methods

public static FacebookConnect getInstance()Gets the FacebookConnect singleton instance .
public boolean isFacebookSDKSupported()Indicates whether the native platform supports native facebook login
public void login()Deprecated Logs into facebook, notice that this call might suspend the application which might trigger repeated invocations of stop()/start() etc. This is due to the facebook SDK spawning a separate process to perform the login then returning to the application.
public void doLogout()Logs out the current user from facebook
public AccessToken getAccessToken()The facebook token that can be used to access facebook functionality
public boolean isLoggedIn()Deprecated Indicates if the user is currently logged in
public String getToken()Deprecated The facebook token that can be used to access facebook functionality
public void logout()Deprecated Logs out the current user from facebook
public void askPublishPermissions(LoginCallback lc)Asks for publish permissions, this call might suspend the application which might trigger repeated invocations of stop()/start().
public boolean hasPublishPermissions()Returns true if the current session already has publish permissions
public boolean isNativeLoginSupported()Returns true if this service supports native login.
protected Oauth2 createOauth2()Creates the oauth2 to be used to login in case no native login is available for this service.
public void nativelogin()Logs in the current user natively.
public void nativeLogout()Logs out the current user natively.
public boolean nativeIsLoggedIn()Indicates if the user is currently logged in.
public void inviteFriends(String appLinkUrl, String previewImageUrl)Deprecated Opens and invite dialog to invite friends to the app https://developers.facebook.com/docs/app-invites
public void inviteFriends(String appLinkUrl, String previewImageUrl, Callback cb)Deprecated Opens and invite dialog to invite friends to the app https://developers.facebook.com/docs/app-invites
public AsyncResource<OidcTokens> signIn(String appId, String redirectUri, String... permissions)Modern Facebook Login.
public boolean isInviteFriendsSupported()Returns true if inviteFriends is implemented, it is supported on iOS and Android
protected boolean validateToken(String token)Returns true if the previous granted access token is still valid otherwise false.

Inherited methods

Method details

getInstance

public static FacebookConnect getInstance()
Gets the FacebookConnect singleton instance .

Returns

the FacebookConnect instance

isFacebookSDKSupported

public boolean isFacebookSDKSupported()
Indicates whether the native platform supports native facebook login

Returns

true if supported

login

public void login()
Deprecated. use doLogin
Logs into facebook, notice that this call might suspend the application which might trigger repeated invocations of stop()/start() etc. This is due to the facebook SDK spawning a separate process to perform the login then returning to the application. Once logged in the facebook credentials will be available.

doLogout

public void doLogout()
Logs out the current user from facebook

getAccessToken

public AccessToken getAccessToken()
The facebook token that can be used to access facebook functionality

Returns

the token

isLoggedIn

public boolean isLoggedIn()
Deprecated. use isUserLoggedIn() instead
Indicates if the user is currently logged in

Returns

true if logged in

getToken

public String getToken()
Deprecated. use getAccessToken instead
The facebook token that can be used to access facebook functionality

Returns

the token

logout

public void logout()
Deprecated. use doLogout instead
Logs out the current user from facebook

askPublishPermissions

public void askPublishPermissions(LoginCallback lc)
Asks for publish permissions, this call might suspend the application which might trigger repeated invocations of stop()/start().

hasPublishPermissions

public boolean hasPublishPermissions()
Returns true if the current session already has publish permissions

isNativeLoginSupported

public boolean isNativeLoginSupported()
Returns true if this service supports native login. If implementation returns true here, the nativelogin, nativelogout, nativeIsLoggedIn should be implemented

Returns

true if the service supports native login

createOauth2

protected Oauth2 createOauth2()
Creates the oauth2 to be used to login in case no native login is available for this service.

Returns

the Oauth2 to be used to login if no native login available and on the simulator

nativelogin

public void nativelogin()
Logs in the current user natively. Subclasses that uses a native sdk to login/logout should override this method.

nativeLogout

public void nativeLogout()
Logs out the current user natively. Subclasses that uses a native sdk to login/logout should override this method.

nativeIsLoggedIn

public boolean nativeIsLoggedIn()
Indicates if the user is currently logged in. Subclasses that uses a native sdk to login/logout should override this method.

Returns

true if logged in

inviteFriends

public void inviteFriends(String appLinkUrl, String previewImageUrl)
Deprecated. The Facebook SDK no longer supports app invites. https://developers.facebook.com/blog/post/2017/11/07/changes-developer-offerings/
Opens and invite dialog to invite friends to the app https://developers.facebook.com/docs/app-invites

Parameters

appLinkUrl String
App Link for what should be opened when the recipient clicks on the install/play button on the app invite page.
previewImageUrl String
url to an image to be used in the invite, can be null

inviteFriends

public void inviteFriends(String appLinkUrl, String previewImageUrl, Callback cb)
Deprecated. The Facebook SDK no longer supports app invites https://developers.facebook.com/blog/post/2017/11/07/changes-developer-offerings/
Opens and invite dialog to invite friends to the app https://developers.facebook.com/docs/app-invites

Parameters

appLinkUrl String
App Link for what should be opened when the recipient clicks on the install/play button on the app invite page.
previewImageUrl String
url to an image to be used in the invite, can be null
cb Callback
a Callback to be used when we need to know if the Facebook invite was successful. If the invite was successful the onSucess method will be called If the user canceled the onError method will be called with error code -1. If an error occurred the onError method will be called with error code 0.

signIn

public AsyncResource<OidcTokens> signIn(String appId, String redirectUri, String... permissions)
Modern Facebook Login. Goes through Facebook’s OAuth 2.0 endpoints via the system browser (SystemBrowser), independent of the native Facebook SDK. Use this method for browser-based and cross-platform consistency; the older doLogin() path remains for code that depends on the iOS/Android Facebook SDK integration.

Parameters

appId String
Facebook App ID.
redirectUri String
Must match a Valid OAuth Redirect URI configured in the app dashboard.
permissions String...
Facebook permissions (public_profile, email, …). Defaults to public_profile email when empty.

Returns

An AsyncResource resolving to the granted access token wrapped in OidcTokens (note: Facebook does not issue OIDC ID tokens for classic OAuth flows – getIdToken() will be null; use getAccessToken() and call the Graph API to read user profile data).

isInviteFriendsSupported

public boolean isInviteFriendsSupported()

Returns true if inviteFriends is implemented, it is supported on iOS and Android

NOTE: Since updating to Facebook SDK 5.6.0 (April 1, 2020), invite friends is no longer supported on iOS. It will eventually be removed from Android as well, as Facebook no longer supports App invites in its native SDKs.

Returns

true if inviteFriends is implemented

validateToken

protected boolean validateToken(String token)
Returns true if the previous granted access token is still valid otherwise false.

Parameters

token String
the access token to check

Returns

true of the token is valid