Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How get the email? #30

Open
Marko1985 opened this issue Jul 27, 2015 · 1 comment
Open

How get the email? #30

Marko1985 opened this issue Jul 27, 2015 · 1 comment

Comments

@Marko1985
Copy link

Hi,

I have setup this: FacebookInAppBrowser.settings.permissions = 'email, public_profile'.
I have this code but I cannot see on alert the email of user to use it on my register process :

function get_user_fb(){
        FacebookInAppBrowser.getInfo(function(response) {
            if(response) {
                var name = response.name;
                var id = response.id;
                var gender = response.gender;
                    //mail = response.email;
                alert(JSON.stringify(response));
                // check the response object to see all available data like email, first name, last name, etc
                //console.log(JSON.stringify(response));
            }
            else{
                alert('No se puede coger ese get');
            }
        });
    } 

    $(document).ready(function(){ 

        if(localStorage.getItem('accessToken') != null || localStorage.getItem('accessToken') != undefined){
             FacebookInAppBrowser.getInfo(function(response) {
                if(response) {
                    var name = response.name,
                        id = response.id,
                        gender = response.gender;

                    // check the response object to see all available data like email, first name, last name, etc
                    $('#register').hide(500, function(){
                        $('#welcome').show(500, function(){
                            $('.your_name').html(name);        
                        });
                    });

                    console.log(JSON.stringify(response));
                }
            });
        }


        $(document.body).on("click",".btn-register", function(){                  
            rytmus.pushPage("home.html", { animation :'slide'});
        });

        $(document.body).on("pageinit","#inicio", function() {

        });

        $('.btn-register-fb').click(function(){
           FacebookInAppBrowser.login({
            send: function() {
                console.log('login opened');
            },
            success: function(access_token) {
                console.log('done, access token: ' + access_token);
            },
            denied: function() {
                console.log('user denied');
            },
            timeout: function(){
                console.log('a timeout has occurred, probably a bad internet connection');
            },
            complete: function(access_token) {
                console.log('window closed');
                if(access_token) {
                    console.log(access_token);
                } else {
                    console.log('no access token');
                }
            },
            userInfo: function(userInfo) {
                if(userInfo) {
                    $('#register').hide(200, function(){
                        $('#welcome').show(200, function(){
                            //$('.your_name').html(userInfo.name); 
                            //graph.facebook.com/{{fid}}/picture
                            $('#img_fb').attr('src', 'https://graph.facebook.com/'+userInfo.id+'/picture');                             
                        });
                    });

                    alert(JSON.stringify(userInfo)); 
                    console.log(JSON.stringify(userInfo));
                } else {
                    alert('No se puede acceder a tu información desde Facebook');
                    console.log('no user info');
                }
            }

});
});
});

    get_user_fb();

Thanks in advance.

@caiovaccaro
Copy link
Owner

Hey,

Please download the .js file again and update your phonegap.facebook.inappbrowser.js. I just updated the function with additional arguments to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants