roughike / flutter_facebook_login

A Flutter plugin for allowing users to authenticate with native Android & iOS Facebook login SDKs.
BSD 2-Clause "Simplified" License
404 stars 332 forks source link

New logIn method (formely loginWithReadPermission) #273

Open placidovlm opened 4 years ago

placidovlm commented 4 years ago

In changelog documentation section there is the text : "...renamed loginWithReadPermission to login" but, the correct is : "...renamed loginWithReadPermission to logIn"

And the "How do I use it?" in Readme documentation section needs update, with renamed method logIn

DyaryRaoof commented 4 years ago
 final result =
        await facebookLogin.logIn(["email", "public_profile", "user_friends"]);
    print(result.errorMessage);
    switch (result.status) {
      case FacebookLoginStatus.loggedIn:
        final token = result.accessToken.token;
        final graphResponse = await http.get(
            'https://graph.facebook.com/v2.12/me?fields=name,picture.width(800).height(800),email&access_token=$token');
        final profile = JSON.jsonDecode(graphResponse.body);
break;
}

then in your profile variable there is :

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

you can get name by using print(profile["name"]