ionic2 facebook login with email info


ionic2 facebook login email get email info

facebook 로그인 정보를 가져올때 기본 프로파일에는 email이 포함되어 있지 않으므로 permissions에 기본 프로파일 및 email을 같이 조회해 주기위한 퍼미션을 설정해 주어야 한다.

public_profile permission is not include email. and add permission "email" at permissions array


 permissions = ["public_profile","email"];

Facebook.api("/me?fields=email,name,gender",  permissions )




facebook 에서 가져올수 있는 내용들은 아래 URL을 참조

https://developers.facebook.com/docs/facebook-login/permissions






doFbLogin(){
        let permissions = new Array();
        let nav = this.navCtrl;
        //the permissions your facebook app needs from the user
        permissions = ["public_profile","email"];
    
        
        Facebook.login(permissions)
        .then(function(response){
          let userId = response.authResponse.userID;
          let params = new Array();
          
          //Getting name and gender properties
          Facebook.api("/me?fields=email,name,gender"permissions)
          .then(function(user) {
            user.picture = "https://graph.facebook.com/" + userId + "/picture?type=large";

            alert(JSON.stringify(user));
            //now we have the users info, let's save it in the NativeStorage
            NativeStorage.setItem('user',
            {
              name: user.name,
              email: user.email,
              gender: user.gender,
              picture: user.picture
            })
            .then(function(){
              //alert("nav.push(UserPage);");
              nav.push(UserPage);
              //nav.setRoot(UserPage);
            }, function (error) {
              console.log(error);
            })
          })
    
        }, function(error){
          console.log(error);
        });
        
  }

덧글

댓글 입력 영역