flutterfacebook-authentication

Flutter : No implementation found for method login on channel app.meedu/flutter_facebook_auth


I am trying to use facebook auth in myy app with flutter.

I did all things in documentation.

also I tried to find solution here but nothing helped me ,for example this post and this post

I add this strings.xml :

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="facebook_app_id">xxxxxxxxxxx</string>
    <string name="fb_login_protocol_scheme">fbxxxxxxxxxxxx</string>
    <string name="facebook_client_token">xxxxxxxxxxxxxxxxx</string>
    <string name="app_name">xxxx</string>
</resources>

in AndroidManifest.xml I add this :

<uses-permission android:name="android.permission.INTERNET"/> // before application

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

<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>
<queries>
        <provider android:authorities="com.facebook.katana.provider.PlatformProvider" />

my function :

final LoginResult result = await FacebookAuth.instance.login();
      if (result.status == LoginStatus.success) {
        accessToken = result.accessToken!;
        isLogined = true;
        final userData = await FacebookAuth.instance.getUserData();   
      } else {
        print(result.status);
        print(result.message);
      }

I get this error [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method login on channel app.meedu/flutter_facebook_auth)


Solution

  • Usually the "No implementation" error is caused when you add a new package and do hot reload, or when the platform isn't supported. Try running the app from cold start. If it still fails, I recommend using firebase_auth package for authentication since it supports multiple providers including Facebook.