Search code examples
facebook-javascript-sdkcordova-pluginsquasar-framework

Cordova plugin facebook4, how to use it?


I am integrating the Facebook login to my hybrid app and for this I have used cordova-plugin-facebook4.

run in cmd

$cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="1854483668193025" --variable APP_NAME="Lojas"

config.xml

<plugin name="cordova-plugin-facebook4" spec="^2.2.0">
        <variable name="APP_ID" value="1854483668193025" />
        <variable name="APP_NAME" value="Lojas" />
</plugin>

run cordova browser

$cordova run browser

error

FB.login() called before FB.init().

console

enter image description here

code

login () {
  window.facebookConnectPlugin.login(['email, public_profile'], 
  this.onSignInSuccess, this.onSignInError)
}

What is wrong?


Solution

  • I discovered that the problem was due to having added the plugin and removed, I removed because the plugin did not work in the browser.

    I followed the steps:

    1. $cordova platform remove android
    2. $cordova platform add android
    3. $cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="1854483668193025" --variable APP_NAME="Lojas"