All Projects → roughike → Flutter_facebook_login

roughike / Flutter_facebook_login

Licence: bsd-2-clause
A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Flutter facebook login

http middleware
A middleware library for Dart's http library.
Stars: ✭ 38 (-90.18%)
Mutual labels:  flutter-plugin
Google nav bar
A modern google style nav bar for flutter.
Stars: ✭ 290 (-25.06%)
Mutual labels:  flutter-plugin
Flutter page transition
This is Flutter Page Transition Package
Stars: ✭ 314 (-18.86%)
Mutual labels:  flutter-plugin
Flutter i18n
This plugin create a binding between your translations from .arb files and your Flutter app.
Stars: ✭ 255 (-34.11%)
Mutual labels:  flutter-plugin
Simple auth
The Simplest way to Authenticate in Flutter
Stars: ✭ 276 (-28.68%)
Mutual labels:  flutter-plugin
Caddy Auth Portal
Authentication Plugin for Caddy v2 implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0 (Github, Google, Facebook, Okta, etc.), SAML Authentication
Stars: ✭ 291 (-24.81%)
Mutual labels:  facebook-login
flutter qq ads
🔥🔥🔥 Flutter 广告插件 -- 优量汇 、广点通、腾讯广告(支持开屏、插屏、激励视频、Banner、信息流、视频贴片)
Stars: ✭ 51 (-86.82%)
Mutual labels:  flutter-plugin
Dna
dna, dart native access. A lightweight dart to native super channel plugin, You can use it to invoke any native code directly in contextual and chained dart code.
Stars: ✭ 355 (-8.27%)
Mutual labels:  flutter-plugin
Flutter swiper
The best swiper for flutter , with multiple layouts, infinite loop. Compatible with Android & iOS.
Stars: ✭ 3,209 (+729.2%)
Mutual labels:  flutter-plugin
Flutter programs
Experiments with Mobile
Stars: ✭ 308 (-20.41%)
Mutual labels:  facebook-login
Flutter tts
Flutter Text to Speech package
Stars: ✭ 263 (-32.04%)
Mutual labels:  flutter-plugin
Qrcode scanner
🛠 Flutter QR code scanner plugin.
Stars: ✭ 274 (-29.2%)
Mutual labels:  flutter-plugin
Equinox
Flutter UI library based on Eva Design System ✨
Stars: ✭ 307 (-20.67%)
Mutual labels:  flutter-plugin
flutter simple dependency injection
A super simple dependency injection implementation for flutter that behaviours like any normal IOC container and does not rely on mirrors
Stars: ✭ 91 (-76.49%)
Mutual labels:  flutter-plugin
Uni links
Flutter plugin for accepting incoming links.
Stars: ✭ 339 (-12.4%)
Mutual labels:  flutter-plugin
KASocialLogins
This is Social login library in which you can login through Facebook , LinkedIn and Google
Stars: ✭ 15 (-96.12%)
Mutual labels:  facebook-login
Alice
HTTP Inspector for Flutter. Allows checking HTTP connections with UI inspector.
Stars: ✭ 296 (-23.51%)
Mutual labels:  flutter-plugin
Youtube player flutter
Flutter plugin for playing or streaming YouTube videos inline using the official iFrame Player API. Supports both Android and iOS platforms.
Stars: ✭ 366 (-5.43%)
Mutual labels:  flutter-plugin
Flutter mlkit
A Flutter plugin to use the Firebase ML Kit.
Stars: ✭ 352 (-9.04%)
Mutual labels:  flutter-plugin
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: ✭ 307 (-20.67%)
Mutual labels:  facebook-login

flutter_facebook_login

pub package Build Status Coverage Status

A Flutter plugin for using the native Facebook Login SDKs on Android and iOS.

AndroidX support

Installation

To get things up and running, you'll have to declare a pubspec dependency in your Flutter project. Also some minimal Android & iOS specific configuration must be done, otherwise your app will crash.

On your Flutter project

See the installation instructions on pub.

Android

This assumes that you've done the "Associate Your Package Name and Default Class with Your App" and "Provide the Development and Release Key Hashes for Your App" in the the Facebook Login documentation for Android site.

After 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.

Once you have the Facebook App ID figured out, you'll have to do two things.

First, copy-paste the following to your strings resource file. If you don't have one, just create it.

<your project root>/android/app/src/main/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Your App Name here.</string>

    <!-- Replace "000000000000" with your Facebook App ID here. -->
    <string name="facebook_app_id">000000000000</string>

    <!--
      Replace "000000000000" with your Facebook App ID here.
      **NOTE**: The scheme needs to start with `fb` and then your ID.
    -->
    <string name="fb_login_protocol_scheme">fb000000000000</string>
</resources>

Then you'll just have to copy-paste the following to your Android Manifest:

<your project root>/android/app/src/main/AndroidManifest.xml

<meta-data android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id"/>

<activity android:name="com.facebook.FacebookActivity"
    android:configChanges=
            "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name" />

<activity
    android:name="com.facebook.CustomTabActivity"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="@string/fb_login_protocol_scheme" />
    </intent-filter>
</activity>

A sample of a complete AndroidManifest file can be found here.

Done!

iOS

This assumes that you've done the "Register and Configure Your App with Facebook" step in the the Facebook Login documentation for iOS site. (Note: you can skip "Step 2: Set up Your Development Environment" and "Step 5: Connect Your App Delegate").

After 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.

Once 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 </dict></plist> tags. (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).

<your project root>/ios/Runner/Info.plist

<key>CFBundleURLTypes</key>
<array>
    <!--
    <dict>
    ... Some other CFBundleURLTypes definition.
    </dict>
    -->
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <!--
              Replace "000000000000" with your Facebook App ID here.
              **NOTE**: The scheme needs to start with `fb` and then your ID.
            -->
            <string>fb000000000000</string>
        </array>
    </dict>
</array>

<key>FacebookAppID</key>

<!-- Replace "000000000000" with your Facebook App ID here. -->
<string>000000000000</string>
<key>FacebookDisplayName</key>

<!-- Replace "YOUR_APP_NAME" with your Facebook App name. -->
<string>YOUR_APP_NAME</string>

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>

A sample of a complete Info.plist file can be found here.

Done!

How do I use it?

The library tries to closely match the native Android & iOS login SDK APIs where possible. For complete API documentation, just see the source code. Everything is documented there.

Since sample code is worth more than one page of documentation, here are the usual cases covered:

import 'package:flutter_facebook_login/flutter_facebook_login.dart';

final facebookLogin = FacebookLogin();
final result = await facebookLogin.logIn(['email']);

switch (result.status) {
  case FacebookLoginStatus.loggedIn:
    _sendTokenToServer(result.accessToken.token);
    _showLoggedInUI();
    break;
  case FacebookLoginStatus.cancelledByUser:
    _showCancelledMessage();
    break;
  case FacebookLoginStatus.error:
    _showErrorOnUI(result.errorMessage);
    break;
}

You can also change the visual appearance of the login dialog. For example:

// Let's force the users to login using the login dialog based on WebViews. Yay!
facebookLogin.loginBehavior = FacebookLoginBehavior.webViewOnly;

The complete API documentation lives with the source code, which can be found here.

Getting the Facebook profile of a signed in user

For now, this feature isn't going to be integrated into this plugin. See the discussion here.

However, you can get do this in four lines of Dart code:

final result = await facebookSignIn.logIn(['email']);
final token = result.accessToken.token;
final graphResponse = await http.get(
            'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email&access_token=${token}');
final profile = JSON.decode(graphResponse.body);

The profile variable will now contain the following information:

{
   "name": "Iiro Krankka",
   "first_name": "Iiro",
   "last_name": "Krankka",
   "email": "iiro.krankka\u0040gmail.com",
   "id": "<user id here>"
}

Troubleshooting

If you haven't completed AndroidX setup in your Flutter project, your project might not build. The simple solution is adding 2 lines in your android/gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

For more, see "AndroidX compatibility" in the official Flutter documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].