{"id":13573640,"url":"https://github.com/roughike/flutter_facebook_login","last_synced_at":"2025-04-04T12:31:19.210Z","repository":{"id":37396622,"uuid":"118768989","full_name":"roughike/flutter_facebook_login","owner":"roughike","description":"A Flutter plugin for allowing users to authenticate with native Android \u0026 iOS Facebook login SDKs.","archived":true,"fork":false,"pushed_at":"2021-03-30T07:58:33.000Z","size":173,"stargazers_count":405,"open_issues_count":163,"forks_count":329,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-27T14:55:33.958Z","etag":null,"topics":["dart","facebook-login","flutter","flutter-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roughike.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"roughike","patreon":"https://www.patreon.com/iirokrankka"}},"created_at":"2018-01-24T13:28:01.000Z","updated_at":"2024-12-24T15:54:34.000Z","dependencies_parsed_at":"2022-07-20T12:02:43.807Z","dependency_job_id":null,"html_url":"https://github.com/roughike/flutter_facebook_login","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fflutter_facebook_login","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fflutter_facebook_login/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fflutter_facebook_login/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roughike%2Fflutter_facebook_login/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roughike","download_url":"https://codeload.github.com/roughike/flutter_facebook_login/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247179713,"owners_count":20897088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","facebook-login","flutter","flutter-plugin"],"created_at":"2024-08-01T15:00:38.771Z","updated_at":"2025-04-04T12:31:18.384Z","avatar_url":"https://github.com/roughike.png","language":"Dart","readme":"# flutter_facebook_login\n\n[![pub package](https://img.shields.io/pub/v/flutter_facebook_login.svg)](https://pub.dartlang.org/packages/flutter_facebook_login)\n [![Build Status](https://travis-ci.org/roughike/flutter_facebook_login.svg?branch=master)](https://travis-ci.org/roughike/flutter_facebook_login) \n [![Coverage Status](https://coveralls.io/repos/github/roughike/flutter_facebook_login/badge.svg)](https://coveralls.io/github/roughike/flutter_facebook_login)\n\nA Flutter plugin for using the native Facebook Login SDKs on Android and iOS.\n\n## AndroidX support\n\n* if you want to **avoid AndroidX**, use version 1.2.0.\n* for [AndroidX Flutter projects](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility), use versions 2.0.0 and up.\n\n## Installation\n\nTo get things up and running, you'll have to declare a pubspec dependency in your Flutter project.\nAlso some minimal Android \u0026 iOS specific configuration must be done, otherwise your app will crash.\n\n### On your Flutter project\n\nSee the [installation instructions on pub](https://pub.dartlang.org/packages/flutter_facebook_login#-installing-tab-).\n\n### Android\n\nThis assumes that you've done the _\"Associate Your Package Name and Default Class with Your App\"_ and\n _\"Provide the Development and Release Key Hashes for Your App\"_ in the [the Facebook Login documentation for Android site](https://developers.facebook.com/docs/facebook-login/android).\n\nAfter you've done that, find out what your _Facebook App ID_ is. You can find your Facebook App ID in your Facebook App's dashboard in the Facebook developer console.\n\nOnce you have the Facebook App ID figured out, you'll have to do two things.\n\nFirst, copy-paste the following to your strings resource file. If you don't have one, just create it.\n\n**\\\u003cyour project root\\\u003e/android/app/src/main/res/values/strings.xml**\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cresources\u003e\n    \u003cstring name=\"app_name\"\u003eYour App Name here.\u003c/string\u003e\n\n    \u003c!-- Replace \"000000000000\" with your Facebook App ID here. --\u003e\n    \u003cstring name=\"facebook_app_id\"\u003e000000000000\u003c/string\u003e\n\n    \u003c!--\n      Replace \"000000000000\" with your Facebook App ID here.\n      **NOTE**: The scheme needs to start with `fb` and then your ID.\n    --\u003e\n    \u003cstring name=\"fb_login_protocol_scheme\"\u003efb000000000000\u003c/string\u003e\n\u003c/resources\u003e\n```\n\nThen you'll just have to copy-paste the following to your _Android Manifest_:\n\n**\\\u003cyour project root\\\u003e/android/app/src/main/AndroidManifest.xml**\n\n```xml\n\u003cmeta-data android:name=\"com.facebook.sdk.ApplicationId\"\n    android:value=\"@string/facebook_app_id\"/\u003e\n\n\u003cactivity android:name=\"com.facebook.FacebookActivity\"\n    android:configChanges=\n            \"keyboard|keyboardHidden|screenLayout|screenSize|orientation\"\n    android:label=\"@string/app_name\" /\u003e\n\n\u003cactivity\n    android:name=\"com.facebook.CustomTabActivity\"\n    android:exported=\"true\"\u003e\n    \u003cintent-filter\u003e\n        \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n        \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n        \u003ccategory android:name=\"android.intent.category.BROWSABLE\" /\u003e\n        \u003cdata android:scheme=\"@string/fb_login_protocol_scheme\" /\u003e\n    \u003c/intent-filter\u003e\n\u003c/activity\u003e\n```\n\nA sample of a complete AndroidManifest file can be found [here](https://github.com/roughike/flutter_facebook_login/blob/master/example/android/app/src/main/AndroidManifest.xml#L39-L56).\n\nDone!\n\n### iOS\n\nThis assumes that you've done the _\"Register and Configure Your App with Facebook\"_ step in the\n[the Facebook Login documentation for iOS site](https://developers.facebook.com/docs/facebook-login/ios).\n(**Note**: you can skip \"Step 2: Set up Your Development Environment\" and \"Step 5: Connect Your App Delegate\").\n\nAfter you've done that, find out what your _Facebook App ID_ is. You can find your Facebook App ID in your Facebook App's dashboard in the Facebook developer console.\n\nOnce you have the Facebook App ID figured out, then you'll just have to copy-paste the following to your _Info.plist_ file, before the ending `\u003c/dict\u003e\u003c/plist\u003e` tags.\n(**NOTE**: If you are using this plugin in conjunction with for example `google_sign_in` plugin, which also requires you to add `CFBundleURLTypes` key into _Info.plist_ file, you need to merge them together).\n\n**\\\u003cyour project root\\\u003e/ios/Runner/Info.plist**\n\n```xml\n\u003ckey\u003eCFBundleURLTypes\u003c/key\u003e\n\u003carray\u003e\n    \u003c!--\n    \u003cdict\u003e\n    ... Some other CFBundleURLTypes definition.\n    \u003c/dict\u003e\n    --\u003e\n    \u003cdict\u003e\n        \u003ckey\u003eCFBundleURLSchemes\u003c/key\u003e\n        \u003carray\u003e\n            \u003c!--\n              Replace \"000000000000\" with your Facebook App ID here.\n              **NOTE**: The scheme needs to start with `fb` and then your ID.\n            --\u003e\n            \u003cstring\u003efb000000000000\u003c/string\u003e\n        \u003c/array\u003e\n    \u003c/dict\u003e\n\u003c/array\u003e\n\n\u003ckey\u003eFacebookAppID\u003c/key\u003e\n\n\u003c!-- Replace \"000000000000\" with your Facebook App ID here. --\u003e\n\u003cstring\u003e000000000000\u003c/string\u003e\n\u003ckey\u003eFacebookDisplayName\u003c/key\u003e\n\n\u003c!-- Replace \"YOUR_APP_NAME\" with your Facebook App name. --\u003e\n\u003cstring\u003eYOUR_APP_NAME\u003c/string\u003e\n\n\u003ckey\u003eLSApplicationQueriesSchemes\u003c/key\u003e\n\u003carray\u003e\n    \u003cstring\u003efbapi\u003c/string\u003e\n    \u003cstring\u003efb-messenger-share-api\u003c/string\u003e\n    \u003cstring\u003efbauth2\u003c/string\u003e\n    \u003cstring\u003efbshareextension\u003c/string\u003e\n\u003c/array\u003e\n```\n\nA sample of a complete Info.plist file can be found [here](https://github.com/roughike/flutter_facebook_login/blob/master/example/ios/Runner/Info.plist#L49-L70).\n\nDone!\n\n## How do I use it?\n\nThe library tries to closely match the native Android \u0026 iOS login SDK APIs where possible. For complete API documentation, just see the [source code](https://github.com/roughike/flutter_facebook_login/blob/master/lib/flutter_facebook_login.dart). Everything is documented there.\n\nSince sample code is worth more than one page of documentation, here are the usual cases covered:\n\n```dart\nimport 'package:flutter_facebook_login/flutter_facebook_login.dart';\n\nfinal facebookLogin = FacebookLogin();\nfinal result = await facebookLogin.logIn(['email']);\n\nswitch (result.status) {\n  case FacebookLoginStatus.loggedIn:\n    _sendTokenToServer(result.accessToken.token);\n    _showLoggedInUI();\n    break;\n  case FacebookLoginStatus.cancelledByUser:\n    _showCancelledMessage();\n    break;\n  case FacebookLoginStatus.error:\n    _showErrorOnUI(result.errorMessage);\n    break;\n}\n```\n\nYou can also change the visual appearance of the login dialog. For example:\n\n```dart\n// Let's force the users to login using the login dialog based on WebViews. Yay!\nfacebookLogin.loginBehavior = FacebookLoginBehavior.webViewOnly;\n```\n\nThe complete API documentation lives with the source code, [which can be found here](https://github.com/roughike/flutter_facebook_login/blob/master/lib/flutter_facebook_login.dart).\n\n### Getting the Facebook profile of a signed in user\n\nFor now, this feature isn't going to be integrated into this plugin. See the [discussion here](https://github.com/roughike/flutter_facebook_login/issues/11).\n\nHowever, you can get do this in four lines of Dart code:\n\n```dart\nfinal result = await facebookSignIn.logIn(['email']);\nfinal token = result.accessToken.token;\nfinal graphResponse = await http.get(\n            'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email\u0026access_token=${token}');\nfinal profile = JSON.decode(graphResponse.body);\n```\n\nThe `profile` variable will now contain the following information:\n\n```json\n{\n   \"name\": \"Iiro Krankka\",\n   \"first_name\": \"Iiro\",\n   \"last_name\": \"Krankka\",\n   \"email\": \"iiro.krankka\\u0040gmail.com\",\n   \"id\": \"\u003cuser id here\u003e\"\n}\n```\n\n### Troubleshooting\n\nIf you haven't completed AndroidX setup in your Flutter project, your project might not build.\nThe simple solution is adding 2 lines in your android/gradle.properties:\n\n```\nandroid.useAndroidX=true\nandroid.enableJetifier=true\n```\n\nFor more, see [\"AndroidX compatibility\" in the official Flutter documentation](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility).\n","funding_links":["https://github.com/sponsors/roughike","https://patreon.com/https://www.patreon.com/iirokrankka"],"categories":["组件","Dart","Components","Auth [🔝](#readme)"],"sub_categories":["验证","身份验证","Auth"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froughike%2Fflutter_facebook_login","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froughike%2Fflutter_facebook_login","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froughike%2Fflutter_facebook_login/lists"}