|
| 1 | +# Parse Facebook Utils for Android |
| 2 | +A utility library to authenticate `ParseUser`s with the Facebook SDK. For more information, see our [guide][guide]. |
| 3 | + |
| 4 | +## Dependency |
| 5 | + |
| 6 | +After including JitPack: |
| 7 | +```gradle |
| 8 | +dependencies { |
| 9 | + implementation "com.github.parse-community.Parse-SDK-Android:facebook:latest.version.here" |
| 10 | +} |
| 11 | +``` |
| 12 | + |
| 13 | +## Usage |
| 14 | +Extensive docs can be found in the [guide](https://docs.parseplatform.org/android/guide/#facebook-users). The basic steps are: |
| 15 | +```java |
| 16 | +// in Application.onCreate(); or somewhere similar |
| 17 | +ParseFacebookUtils.initialize(context); |
| 18 | +``` |
| 19 | +Within the activity where your user is going to log in with Facebook, include the following: |
| 20 | +```java |
| 21 | +@Override |
| 22 | +protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 23 | + super.onActivityResult(requestCode, resultCode, data); |
| 24 | + ParseFacebookUtils.onActivityResult(requestCode, resultCode, data); |
| 25 | +} |
| 26 | +``` |
| 27 | +Then elsewhere, when your user taps the login button: |
| 28 | +```java |
| 29 | +ParseFacebookUtils.logInWithReadPermissionsInBackground(this, permissions, new LogInCallback() { |
| 30 | + @Override |
| 31 | + public void done(ParseUser user, ParseException err) { |
| 32 | + if (user == null) { |
| 33 | + Log.d("MyApp", "Uh oh. The user cancelled the Facebook login."); |
| 34 | + } else if (user.isNew()) { |
| 35 | + Log.d("MyApp", "User signed up and logged in through Facebook!"); |
| 36 | + } else { |
| 37 | + Log.d("MyApp", "User logged in through Facebook!"); |
| 38 | + } |
| 39 | + } |
| 40 | +}); |
| 41 | +``` |
| 42 | + |
| 43 | +## License |
| 44 | + Copyright (c) 2015-present, Parse, LLC. |
| 45 | + All rights reserved. |
| 46 | + |
| 47 | + This source code is licensed under the BSD-style license found in the |
| 48 | + LICENSE file in the root directory of this source tree. An additional grant |
| 49 | + of patent rights can be found in the PATENTS file in the same directory. |
0 commit comments