public final class ParseFacebookUtils extends Object
ParseFacebookUtils
, you must add the Facebook Android SDK to your project.Modifier and Type | Method and Description |
---|---|
static void |
extendAccessToken(com.parse.ParseUser user,
Context context,
com.parse.SaveCallback callback)
Deprecated.
This is now handled automatically by the Facebook SDK.
|
static boolean |
extendAccessTokenIfNeeded(com.parse.ParseUser user,
Context context,
com.parse.SaveCallback callback)
Deprecated.
This is now handled automatically by the Facebook SDK.
|
static void |
finishAuthentication(int requestCode,
int resultCode,
Intent data)
Completes authentication after the Facebook app returns an activity result.
|
static Facebook |
getFacebook()
Deprecated.
Please use
ParseFacebookUtils.getSession() and related Facebook SDK 3.0+ APIs instead. |
static Session |
getSession() |
static void |
initialize()
Deprecated.
Please use
ParseFacebookUtils.initialize(Context) instead. |
static void |
initialize(Context context)
Initializes Facebook for use with Parse.
|
static void |
initialize(Context context,
String appId)
Initializes Facebook with a custom
appId for use with Parse. |
static void |
initialize(String appId)
Deprecated.
Please use
ParseFacebookUtils.initialize(Context, String) instead. |
static boolean |
isLinked(com.parse.ParseUser user) |
static void |
link(com.parse.ParseUser user,
Activity activity)
Deprecated.
Please use
ParseFacebookUtils.linkInBackground(ParseUser, android.app.Activity) instead. |
static void |
link(com.parse.ParseUser user,
Activity activity,
int activityCode)
Deprecated.
Please use
ParseFacebookUtils.linkInBackground(ParseUser, android.app.Activity, int) instead. |
static void |
link(com.parse.ParseUser user,
Activity activity,
int activityCode,
com.parse.SaveCallback callback) |
static void |
link(com.parse.ParseUser user,
Activity activity,
com.parse.SaveCallback callback) |
static void |
link(com.parse.ParseUser user,
Collection<String> permissions,
Activity activity)
Deprecated.
|
static void |
link(com.parse.ParseUser user,
Collection<String> permissions,
Activity activity,
int activityCode)
Deprecated.
|
static void |
link(com.parse.ParseUser user,
Collection<String> permissions,
Activity activity,
int activityCode,
com.parse.SaveCallback callback)
Links a ParseUser to a Facebook account, allowing you to use Facebook for authentication, and
providing access to Facebook data for the user.
|
static void |
link(com.parse.ParseUser user,
Collection<String> permissions,
Activity activity,
com.parse.SaveCallback callback)
Links a user using the default activity code if single sign-on is enabled.
|
static void |
link(com.parse.ParseUser user,
String facebookId,
String accessToken,
Date expirationDate)
Deprecated.
Please use
ParseFacebookUtils.linkInBackground(ParseUser, String, String, java.util.Date)
instead. |
static void |
link(com.parse.ParseUser user,
String facebookId,
String accessToken,
Date expirationDate,
com.parse.SaveCallback callback)
Links a ParseUser to a Facebook account, allowing you to use Facebook for authentication, and
providing access to Facebook data for the user.
|
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
Activity activity) |
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
Activity activity,
int activityCode) |
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
Collection<String> permissions,
Activity activity) |
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
Collection<String> permissions,
Activity activity,
int activityCode)
Links a ParseUser to a Facebook account, allowing you to use Facebook for authentication, and
providing access to Facebook data for the user.
|
static Task<Void> |
linkInBackground(com.parse.ParseUser user,
String facebookId,
String accessToken,
Date expirationDate)
Links a ParseUser to a Facebook account, allowing you to use Facebook for authentication, and
providing access to Facebook data for the user.
|
static void |
logIn(Activity activity,
int activityCode,
com.parse.LogInCallback callback) |
static void |
logIn(Activity activity,
com.parse.LogInCallback callback) |
static void |
logIn(Collection<String> permissions,
Activity activity,
int activityCode,
com.parse.LogInCallback callback)
Logs in a ParseUser using Facebook for authentication.
|
static void |
logIn(Collection<String> permissions,
Activity activity,
com.parse.LogInCallback callback)
Logs in a user using the default activity code if single sign-on is enabled.
|
static void |
logIn(String facebookId,
String accessToken,
Date expirationDate,
com.parse.LogInCallback callback)
Logs in a ParseUser using Facebook for authentication.
|
static Task<com.parse.ParseUser> |
logInInBackground(Collection<String> permissions,
Activity activity,
int activityCode)
Logs in a ParseUser using Facebook for authentication.
|
static Task<com.parse.ParseUser> |
logInInBackground(String facebookId,
String accessToken,
Date expirationDate)
Logs in a ParseUser using Facebook for authentication.
|
static void |
saveLatestSessionData(com.parse.ParseUser user)
Deprecated.
Please use
ParseFacebookUtils.saveLatestSessionDataInBackground(ParseUser) instead. |
static void |
saveLatestSessionData(com.parse.ParseUser user,
com.parse.SaveCallback callback)
Saves the latest session data to the user.
|
static Task<Void> |
saveLatestSessionDataInBackground(com.parse.ParseUser user)
Saves the latest session data to the user.
|
static boolean |
shouldExtendAccessToken(com.parse.ParseUser user)
Deprecated.
This is now handled automatically by the Facebook SDK.
|
static void |
unlink(com.parse.ParseUser user)
Unlinks a user from a Facebook account.
|
static Task<Void> |
unlinkInBackground(com.parse.ParseUser user)
Unlinks a user from a Facebook account in the background.
|
static void |
unlinkInBackground(com.parse.ParseUser user,
com.parse.SaveCallback callback)
Unlinks a user from a Facebook account in the background.
|
@Deprecated public static Facebook getFacebook()
ParseFacebookUtils.getSession()
and related Facebook SDK 3.0+ APIs instead.public static Session getSession()
public static boolean isLinked(com.parse.ParseUser user)
true
if the user is linked to a Facebook account.@Deprecated public static void initialize()
ParseFacebookUtils.initialize(Context)
instead.public static void initialize(Context context)
Activity.onActivityResult(int, int, android.content.Intent)
method to invoke
ParseFacebookUtils.finishAuthentication(int, int, Intent)
.context
- The application context.ParseFacebookUtils.logIn(Collection, Activity, int, LogInCallback)
,
ParseFacebookUtils.link(ParseUser, Collection, Activity, int, SaveCallback)
@Deprecated public static void initialize(String appId)
ParseFacebookUtils.initialize(Context, String)
instead.public static void initialize(Context context, String appId)
appId
for use with Parse.
This method is only required if you intend to use a different appId
than is defined by
com.facebook.sdk.ApplicationId
in your AndroidManifest.xml
. You may also invoke
this method more than once if you need to change the appId.
IMPORTANT: If you choose to enable single sign-on, you must override the
Activity.onActivityResult(int, int, android.content.Intent)
method to invoke
ParseFacebookUtils.finishAuthentication(int, int, Intent)
.context
- The application context.appId
- The Facebook appId for your application.ParseFacebookUtils.logIn(Collection, Activity, int, LogInCallback)
,
ParseFacebookUtils.link(ParseUser, Collection, Activity, int, SaveCallback)
public static void unlink(com.parse.ParseUser user) throws com.parse.ParseException
user
- The user to unlink from Facebook.com.parse.ParseException
public static Task<Void> unlinkInBackground(com.parse.ParseUser user)
user
- The user to unlink from Facebook.public static void unlinkInBackground(com.parse.ParseUser user, com.parse.SaveCallback callback)
user
- The user to unlink from a Facebook account.callback
- Callback for notifying when unlinking is complete.public static Task<Void> linkInBackground(com.parse.ParseUser user, String facebookId, String accessToken, Date expirationDate)
user
- The user to link to a Facebook account.facebookId
- The facebook ID of the user being linked.accessToken
- The access token for the user.expirationDate
- The expiration date of the access token.@Deprecated public static void link(com.parse.ParseUser user, String facebookId, String accessToken, Date expirationDate)
ParseFacebookUtils.linkInBackground(ParseUser, String, String, java.util.Date)
instead.public static void link(com.parse.ParseUser user, String facebookId, String accessToken, Date expirationDate, com.parse.SaveCallback callback)
user
- The user to link to a Facebook account.facebookId
- The facebook ID of the user being linked.accessToken
- The access token for the user.expirationDate
- The expiration date of the access token.callback
- Callback for notifying when the new authentication data has been saved to the user.public static Task<Void> linkInBackground(com.parse.ParseUser user, Collection<String> permissions, Activity activity, int activityCode)
authenticate()
method.
IMPORTANT: Note that single sign-on authentication will not function correctly if you do
not include a call to the finishAuthentication()
method in your onActivityResult()
function! Please see below for more information.
From the Facebook SDK documentation:
Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant
the requested permissions to the given application.
This method will, when possible, use Facebook's single sign-on for Android to obtain an access
token. This involves proxying a call through the Facebook for Android stand-alone application,
which will handle the authentication flow, and return an OAuth access token for making API
calls.
Because this process will not be available for all users, if single sign-on is not possible,
this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the
user credentials are handled by Facebook in an embedded WebView, not by the client application.
As such, the dialog makes a network request and renders HTML content rather than a native UI.
The access token is retrieved from a redirect to a special URL that the WebView handles.user
- The user to link to a Facebook account.permissions
- A list of permissions to be used when logging in. Many of these constants are defined
here: ParseFacebookUtils.Permissions
.activity
- The Android activity in which we want to display the authorization dialog.activityCode
- Single sign-on requires an activity result to be called back to the client application
-- if you are waiting on other activities to return data, pass a custom activity code
here to avoid collisions.public static Task<Void> linkInBackground(com.parse.ParseUser user, Collection<String> permissions, Activity activity)
ParseFacebookUtils.linkInBackground(ParseUser, java.util.Collection, android.app.Activity, int)
,
FacebookAuthenticationProvider.DEFAULT_AUTH_ACTIVITY_CODE
public static Task<Void> linkInBackground(com.parse.ParseUser user, Activity activity, int activityCode)
public static Task<Void> linkInBackground(com.parse.ParseUser user, Activity activity)
ParseFacebookUtils.linkInBackground(ParseUser, java.util.Collection, android.app.Activity, int)
,
FacebookAuthenticationProvider.DEFAULT_AUTH_ACTIVITY_CODE
public static void link(com.parse.ParseUser user, Collection<String> permissions, Activity activity, int activityCode, com.parse.SaveCallback callback)
authenticate()
method.
IMPORTANT: Note that single sign-on authentication will not function correctly if you do
not include a call to the finishAuthentication()
method in your onActivityResult()
function! Please see below for more information.
From the Facebook SDK documentation:
Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant
the requested permissions to the given application.
This method will, when possible, use Facebook's single sign-on for Android to obtain an access
token. This involves proxying a call through the Facebook for Android stand-alone application,
which will handle the authentication flow, and return an OAuth access token for making API
calls.
Because this process will not be available for all users, if single sign-on is not possible,
this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the
user credentials are handled by Facebook in an embedded WebView, not by the client application.
As such, the dialog makes a network request and renders HTML content rather than a native UI.
The access token is retrieved from a redirect to a special URL that the WebView handles.user
- The user to link to a Facebook account.permissions
- A list of permissions to be used when logging in. Many of these constants are defined
here: ParseFacebookUtils.Permissions
.activity
- The Android activity in which we want to display the authorization dialog.activityCode
- Single sign-on requires an activity result to be called back to the client application
-- if you are waiting on other activities to return data, pass a custom activity code
here to avoid collisions.callback
- Callback for notifying the calling application when the Facebook authentication has
completed, failed, or been canceled.public static void link(com.parse.ParseUser user, Collection<String> permissions, Activity activity, com.parse.SaveCallback callback)
@Deprecated public static void link(com.parse.ParseUser user, Collection<String> permissions, Activity activity, int activityCode)
ParseFacebookUtils.linkInBackground(ParseUser, java.util.Collection,
android.app.Activity, int)
instead.@Deprecated public static void link(com.parse.ParseUser user, Collection<String> permissions, Activity activity)
ParseFacebookUtils.linkInBackground(ParseUser, java.util.Collection,
android.app.Activity)
instead.public static void link(com.parse.ParseUser user, Activity activity, int activityCode, com.parse.SaveCallback callback)
public static void link(com.parse.ParseUser user, Activity activity, com.parse.SaveCallback callback)
@Deprecated public static void link(com.parse.ParseUser user, Activity activity, int activityCode)
ParseFacebookUtils.linkInBackground(ParseUser, android.app.Activity, int)
instead.@Deprecated public static void link(com.parse.ParseUser user, Activity activity)
ParseFacebookUtils.linkInBackground(ParseUser, android.app.Activity)
instead.public static Task<com.parse.ParseUser> logInInBackground(String facebookId, String accessToken, Date expirationDate)
facebookId
- The facebook ID of the user being linked.accessToken
- The access token for the user.expirationDate
- The expiration date of the access token.public static void logIn(String facebookId, String accessToken, Date expirationDate, com.parse.LogInCallback callback)
facebookId
- The facebook ID of the user being linked.accessToken
- The access token for the user.expirationDate
- The expiration date of the access token.callback
- Callback for notifying when the new authentication data has been saved to the user.public static Task<com.parse.ParseUser> logInInBackground(Collection<String> permissions, Activity activity, int activityCode)
authenticate()
method.
IMPORTANT: Note that single sign-on authentication will not function correctly if you do
not include a call to the finishAuthentication()
method in your onActivityResult()
function! Please see below for more information.
From the Facebook SDK documentation:
Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant
the requested permissions to the given application.
This method will, when possible, use Facebook's single sign-on for Android to obtain an access
token. This involves proxying a call through the Facebook for Android stand-alone application,
which will handle the authentication flow, and return an OAuth access token for making API
calls.
Because this process will not be available for all users, if single sign-on is not possible,
this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the
user credentials are handled by Facebook in an embedded WebView, not by the client application.
As such, the dialog makes a network request and renders HTML content rather than a native UI.
The access token is retrieved from a redirect to a special URL that the WebView handles.permissions
- A list of permissions to be used when logging in. Many of these constants are defined
here: ParseFacebookUtils.Permissions
.activity
- The Android activity in which we want to display the authorization dialog.activityCode
- Single sign-on requires an activity result to be called back to the client application
-- if you are waiting on other activities to return data, pass a custom activity code
here to avoid collisions.public static void logIn(Collection<String> permissions, Activity activity, int activityCode, com.parse.LogInCallback callback)
authenticate()
method.
IMPORTANT: Note that single sign-on authentication will not function correctly if you do
not include a call to the finishAuthentication()
method in your onActivityResult()
function! Please see below for more information.
From the Facebook SDK documentation:
Starts either an Activity or a dialog which prompts the user to log in to Facebook and grant
the requested permissions to the given application.
This method will, when possible, use Facebook's single sign-on for Android to obtain an access
token. This involves proxying a call through the Facebook for Android stand-alone application,
which will handle the authentication flow, and return an OAuth access token for making API
calls.
Because this process will not be available for all users, if single sign-on is not possible,
this method will automatically fall back to the OAuth 2.0 User-Agent flow. In this flow, the
user credentials are handled by Facebook in an embedded WebView, not by the client application.
As such, the dialog makes a network request and renders HTML content rather than a native UI.
The access token is retrieved from a redirect to a special URL that the WebView handles.permissions
- A list of permissions to be used when logging in. Many of these constants are defined
here: ParseFacebookUtils.Permissions
.activity
- The Android activity in which we want to display the authorization dialog.activityCode
- Single sign-on requires an activity result to be called back to the client application
-- if you are waiting on other activities to return data, pass a custom activity code
here to avoid collisions.callback
- Callback for notifying the calling application when the Facebook authentication has
completed, failed, or been canceled.public static void logIn(Activity activity, int activityCode, com.parse.LogInCallback callback)
public static void logIn(Collection<String> permissions, Activity activity, com.parse.LogInCallback callback)
public static void logIn(Activity activity, com.parse.LogInCallback callback)
public static void finishAuthentication(int requestCode, int resultCode, Intent data)
ParseFacebookUtils.logIn(Activity, int, LogInCallback)
or
ParseFacebookUtils.link(ParseUser, Activity, int, SaveCallback)
methods in ParseFacebookUtilities
. For more information, see http://developer.android.com/reference/android/app/
Activity.html#onActivityResult(int, int, android.content.Intent)public static Task<Void> saveLatestSessionDataInBackground(com.parse.ParseUser user)
user
- The user whose session information should be updated.public static void saveLatestSessionData(com.parse.ParseUser user, com.parse.SaveCallback callback)
user
- The user whose session information should be updated.callback
- Callback invoked when the session data has been saved.@Deprecated public static void saveLatestSessionData(com.parse.ParseUser user)
ParseFacebookUtils.saveLatestSessionDataInBackground(ParseUser)
instead.@Deprecated public static boolean shouldExtendAccessToken(com.parse.ParseUser user)
@Deprecated public static void extendAccessToken(com.parse.ParseUser user, Context context, com.parse.SaveCallback callback)
@Deprecated public static boolean extendAccessTokenIfNeeded(com.parse.ParseUser user, Context context, com.parse.SaveCallback callback)