Home » Javascript » Error TypeError: this.onready is not a function from internal browser of the facebook IOS application

Error TypeError: this.onready is not a function from internal browser of the facebook IOS application

Posted by: admin October 29, 2018 Leave a comment

Questions:

I integrated my project with Facebook authorization https://developers.facebook.com/docs/facebook-login/web

The Rollbar shows next error

TypeError: this.onready is not a function. (In ‘this.onready(a)’,
‘this.onready’ is undefined)

from file https://connect.facebook.net/en_US/sdk.js from the internal browser of the facebook IOS application (version 172, 171, 170).

Tell me please what the problem is and how to fix it?

$.ajaxSetup({cache: true});
window.fbAsyncInit = function() {
    if(typeof FB != 'undefined'){
        FB.init({
          appId      : fb_app_id,
          cookie     : true,
          xfbml      : true,
          version    : 'v2.8'
        });

        FB.getLoginStatus(function(response) {
            if (response.status == 'connected') {
                    onLogin(response);
                } else {
                FB.login(function(response) {
                    onLogin(response);
                }, {scope: 'user_friends, email'});
            }
        });
    }
    else{
        Rollbar.debug("Not loaded base SDK");
        return false;
    }
};

(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

function checkLoginState() {

    if(typeof FB == 'undefined'){
        Rollbar.debug("FB is undefined. Was a problem loading the Facebook resources. Maybe your provider temporarily blocks this resource");
        return false;
    }

    FB.getLoginStatus(function(response) {
        onLogin(response);
    });
}
Answers: