How to detect when facebook's FB.init is complete

后端 未结 12 2262
我寻月下人不归
我寻月下人不归 2020-11-28 01:28

The old JS SDK had a function called FB.ensureInit. The new SDK does not seem to have such function... how can I ensure that I do not make api calls until it is fully initia

12条回答
  •  温柔的废话
    2020-11-28 02:06

    Another way to check if FB has initialized is by using the following code:

    ns.FBInitialized = function () {
        return typeof (FB) != 'undefined' && window.fbAsyncInit.hasRun;
    };
    

    Thus in your page ready event you could check ns.FBInitialized and defer the event to later phase by using setTimeOut.

提交回复
热议问题