Phonegap Facebook plugin not responding

173 Views Asked by At

I'm trying to get the Phonegap Facebook plugin to work, but no errors occur and the plugin's login() function just doesn't do anything (it's being called, but doesn't do anything).

Whenever I try to install the plugin in the Cordova CLI, I get a Plugin already installed notice. I've added the plugin files manually, by adding FacebookConnectPlugin.h and FacebookConnectPlugin.m in the plugins folder. I've added the FacebookSDK.framework to the frameworks folder. However, when I open my app and tap on the login button (which correctly calls the function), nothing happens. The activity console in Xcode doesn't show any errors and no action is performed.

My JS code looks like this:

var login = function () {
    if (!window.cordova) {
        var appId = prompt("<MyAppId>", "");
        facebookConnectPlugin.browserInit(appId);
    }
    facebookConnectPlugin.login( ["email"],
        function (response) { alert(JSON.stringify(response)) },
        function (response) { alert(JSON.stringify(response)) });
}

$('.login-btn').click(function() {
    login();
});

What step am I missing to make this work? The plugin can be found here.

Also, when I start the app the activity console shows the following info:

2015-10-20 19:58:38.586 MyApp[5143:2355309] Apache Cordova native platform version 3.8.0 is starting. 2015-10-20 19:58:38.590 MyApp[5143:2355309] Multi-tasking -> Device: YES, App: YES 2015-10-20 19:58:38.595 MyApp[5143:2355309] Unlimited access to network resources 2015-10-20 19:58:39.033 MyApp[5143:2355309] Resetting plugins due to page load. 2015-10-20 19:58:39.711 MyApp[5143:2355309] Finished load of: file:///var/mobile/Containers/Bundle/Application/365E079A-56F7-4874-9914-182A57D6DFED/Qwest.app/www/index.html

1

There are 1 best solutions below

0
On BEST ANSWER

Adding plugins manually in cordova usually leads to bad things, especially in the future if you ever want to update. For now I would try removing and adding the plugin:

cordova plugin rm phonegap-facebook-plugin 
cordova plugin -d add -d plugin add /path/to/cloned/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"

(You did follow the instructions at https://github.com/Wizcorp/phonegap-facebook-plugin/blob/master/platforms/ios/README.md on how to install the plugin and cloned it to a different directory) See if that works, if not go with the more nuclear option of adding and removing the platform.

cordova platform rm ios
cordova platform add ios

This is sometimes required, but should only be performed if you have made no changes to the XCode project.

Also the plugin has been forked and https://github.com/jeduan/cordova-plugin-facebook4 which uses the Facebook4 SDK rather than Facebook3 SDK, as well it requires less fiddling to get the IOS plugin to work. It is api compatible so it should just work.