0
votes

I am developing facebook login using Apache Cordova Facebook plugin. The app is built in Phonegap build - android platform. It seems to be a very simple process to build, however I am stuck since yesterday in this error. My Steps:

Step 1. Add plugin in config.xml - My file is:

< ?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>42ch</name>
    <description>Hello World sample application that responds to the deviceready event.</description>
    <author email="[email protected]" href="http://phonegap.com">PhoneGap Team</author>
    <content src="index.html" />
    <preference name="permissions" value="none" />
    <preference name="orientation" value="landscape" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="15" />
    <preference name="android-installLocation" value="auto" />
    <icon src="icon.png" />
    <icon gap:platform="android" gap:qualifier="ldpi" src="www/res/icon/android/icon-36-ldpi.png" />
    <icon gap:platform="android" gap:qualifier="mdpi" src="www/res/icon/android/icon-48-mdpi.png" />
    <icon gap:platform="android" gap:qualifier="hdpi" src="www/res/icon/android/icon-72-hdpi.png" />
    <icon gap:platform="android" gap:qualifier="xhdpi" src="www/res/icon/android/icon-96-xhdpi.png" />
    <icon gap:platform="blackberry" src="www/res/icon/blackberry/icon-80.png" />
    <icon gap:platform="blackberry" gap:state="hover" src="www/res/icon/blackberry/icon-80.png" />
    <icon gap:platform="ios" height="57" src="www/res/icon/ios/icon-57.png" width="57" />
    <icon gap:platform="ios" height="72" src="www/res/icon/ios/icon-72.png" width="72" />
    <icon gap:platform="ios" height="114" src="www/res/icon/ios/icon-57-2x.png" width="114" />
    <icon gap:platform="ios" height="144" src="www/res/icon/ios/icon-72-2x.png" width="144" />
    <icon gap:platform="webos" src="www/res/icon/webos/icon-64.png" />
    <icon gap:platform="winphone" src="www/res/icon/windows-phone/icon-48.png" />
    <icon gap:platform="winphone" gap:role="background" src="www/res/icon/windows-phone/icon-173-tile.png" />
    <access origin="*" />
    <plugin name="cordova-plugin-whitelist" version="1" />
    <gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0">
        <param name="APP_ID" value="My APP ID" />
        <param name="APP_NAME" value="MY APP NAME" />
    </gap:plugin>
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <engine name="android" spec="~4.1.1" />
</widget>

Plugin Tab in phonegap build shows: Plugin | Source | Version | Latest | Installed | Platforms com.phonegap.plugins.facebookconnect | pgb | 0.9.0 | 0.9.0 | 0.9.0 | android,ios

The line of code where the error comes (when I click a button login() is called):

var login = function() {
         if (!window.cordova) {
             facebookConnectPlugin.browserInit('MY APP ID'); // THE CODE WHERE ERROR OCCURS
             alert('a');
         }
         alert('b');
         facebookConnectPlugin.login(["email"], function(response) {
             alert('c');
             if (response.authResponse) {
                 facebookConnectPlugin.api('/me', null,
                     function(response) {
                         alert('Good to see you, ' +
                             response.email + response.name + '.');
                     });

             }
         });
     }

Any help will be hugely appreciated. My code is at https://github.com/sandeepy02/42c

1

1 Answers

0
votes

@user1517108,
it apparent this is your first app. Please read the blog from now on. You have made two (2) mistakes related to recent blog posts.

  1. We are now using NPM as a source for plugings. Please read the blog post.
  2. You are using the wrong plugin. That version is non-grata (unwelcome for development). Use this version.

Use this entry in place of what you have.

<plugin name="cordova-plugin-facebookconnect-orlando" spec="0.11.0" />

You should also read the documentation on how to write a plugin entry. This has changed. Read the blog post for details. – Best of Luck.