Help with Facebook API Integration error

Hi, I’m trying to integrate Facebook API for Facebook login and Facebook leaderboard into my game using the Faceboom API tutorial available in Playcanvas Tutorial segment. While following through the tutorial I have encountered a problem while trying to add the “facebook-setup.js” to the root of the project as a script component. The error is “Uncaught error: Uncaught TypeError: cannot read property ‘on’ of null”. Project Link. Someone please help me…

(function () {
    var _fb = false;
    var _pc = false;
    var _inst = null;
    var app = null;
    window.fbAsyncInit = function() {
            appId      : '277723253076089',
            xfbml      : true,
            version    : 'v2.5'

        _fb = true;

        if (_fb && app) {
    app = pc.Application.getApplication(); // I think this is not initializing the 'app' variable, thus I'm getting null error.
    app.on("initialize", function () {
        if (_fb) {

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