lundi 23 mai 2016

Facebook Login Javascript

I'm trying to create a HTML button with the facebook-jssdk but it seems to be some problems of compatibility.

On chrome, the login dialog works sometimes but on firefox, and some others web navigators like 'IE, Opera,..', the facebook pop up doesn't work.

The problem seem to be come from the function isReady(). isReady return always false where it should be not !

This is the code of the button:

   $scope.rerequest = function() {
        Facebook.login(
          function(response) {
            $scope.checkperm();
          }, {scope: 'email', auth_type: 'rerequest'});
    };



    $scope.checkperm = function(token) {
        Facebook.api('/me/permissions', function (resp) {
            console.log("perm = ", resp);
            if (resp.data && resp.data[1].status != 'granted') {
                $scope.rerequest();
            }
            else
                $scope.signinfb(token);
        });
    };

    $scope.fb_login = function () {
        if (Facebook.isReady() === false)
            return;
        Facebook.login(function (response) {
            $scope.checkperm(response.authResponse.accessToken);
        }, {scope: 'public_profile, email'});
    };

and the code which is called when user load the web site:

FacebookProvider.init('359086750881624');
routeApp.run([function() {

(function(d) {
    // load the Facebook javascript SDK                                                                                                                                                                                                    
    var js,
        id = 'facebook-jssdk',
        ref = d.getElementsByTagName('script')[0];

    if (d.getElementById(id)) {
        return;
    }
    js = d.createElement('script');
    js.id = id;
    js.async = true;
    js.src = "//connect.facebook.net/en_US/sdk.js";

    ref.parentNode.insertBefore(js, ref);

}(document));
}]);

I didn't find anything to be in relation with my problem..

ps: On my Facebook Dev account, the Site URL is on my website.

Aucun commentaire:

Enregistrer un commentaire