phonegap-facebook-login-tutorial

Cordova plugin facebook allows the developers to enable social login for their applications. this plugin is used of authentication purpose and we can also get user’s information such as public profile, birthday, friends list and much more.

phonegap-facebook-login-tutorial
phonegap-facebook-login-tutorial

We also have few advantages with this social login, such as increased conversion rate, easy to authenticate, no password and much more.

Adding Plugin

Create Facebook ID & Application

cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="YOUR_FB_APPID" --variable APP_NAME="YOUR_FB_APPNAME"

Example Code

function loginWithFB(){
  facebookConnectPlugin.login(["public_profile","email"],function(result){
    //calling api after login success
     facebookConnectPlugin.api("/me?fields=email,name,picture",
     ["public_profile","email"]
     ,function(userData){
         //API success callback
         alert(JSON.stringify(userData));
      },function(error){
         //API error callback
         alert(JSON.stringify(error));
      });
   },function(error){
      //authenication error callback
      alert(JSON.stringify(error));
     });
}

ReadMore

https://github.com/jeduan/cordova-plugin-facebook4