0

I'm sure this is going to be so trivial, but have had a number of tries and being the last thing I need to configure before I can deploy the private test is driving me mad.

This question extends off this question, my config.xml is established in the same way, this part is a no brainer. I have also got in my <head>:

<script type='text/javascript' src="./js/facebookConnectPlugin.js"></script>

I have tried both ./facebookConnectPlugin.js as well as ./js/facebookConnectPlugin.js, so part (a) of my question is, how can I determine what is the correct relative path without seeing the directory? I can't find its install location to verify.

Next part of the question follows the advice I received from somewhere, that instead of using the usual device ready event, to use the window.onload:

window.onload = onDeviceReady;
...
function onDeviceReady() {
    onDeviceReadyFacebook();
    ...
}
...
function onDeviceReadyFacebook() {
    // ?
}
window.fbAsyncInit = function () {
    if (!window.cordova) {
        // Initialize - only executed when testing in the browser.
        facebookConnectPlugin.browserInit(<APP_ID>);
    }
}

I have tried the window.fbAsyncInit both inside and out of the call I make for onDeviceReadyFacebook, trying to follow the advice from different forums...

So finally the error occurs within the call I have made to login:

function fb_login(){
    var login_data = {};

    client.cmd          = "login";
    login_data.userid   = user_id;
    login_data.cmd      = "login";

    facebookConnectPlugin.login([
        'user_about_me',
        'email',
        'user_status',
        'user_posts',
        'user_photos',
        'user_videos',
        'user_friends'
    ],function(response) {
        // success
        ...

Saying that the facebookConnectPlugin is undefined. After sligthly modifying different areas and everything else about the app is working, I would generally say that I'm not specifying the right source url for the primary JS file...

One last question on this topic: if I have correctly put in my Content Security Policy, is there any reason I need to use a plugin when I can just use the Facebook all.js they provide as is used in the browser version? I have got my key hash and other properties defined to add the android platform, I would have thought I can specify those attributes to match the platform...

EDIT: The plugin branch in question is located here.

UPDATE 2: @JesseMonroy650: Yes; a few things are definitely becoming clearer, but I did switch to cordova-plugin-facebookconnect-orlando, but adding that made the build crash, the log file result saying the message "...-FacebookLib/ant-build does not exist". I found the exact problem happening here, so I've now tried the same npm plugin and preference settings that was used there. It now builds, but I have the same problem (facebookConnectPlugin is undefined).

However, I checked the repo again this morning, specifically the path:

/platforms/android/assets/www/index.html

To see what I am crucially missing :

<div id="fb-root"></div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/facebookConnectPlugin.js">/script>

So hopefully if I copy off this example, I should be alright now. Will be trying again tonight.

Any help is always very appreciated!

Community
  • 1
  • 1
Jester
  • 399
  • 2
  • 3
  • 15
  • Okay. You are way out in left field. I'm sure where you got any of that; perhaps an outdated example. I'm going to answer on your other post. You may want to kill this. Then again, you have so many misconceptions I might want to make comments here. –  Nov 17 '15 at 04:53
  • Are you making any headway? –  Nov 18 '15 at 07:52

1 Answers1

0

The code added to index.html has finally resolved the issue. I tidied up the actual call to the login as demonstrated, but ultimately the variable wasn't found because I hadn't done the script include. Confusion over the scripts to include and what path they would be.

BIG relief!!! Props to you @JesseMonroy650 for steering me in the right direction of a deprecated plugin.

Jester
  • 399
  • 2
  • 3
  • 15