Ionic 2 + Facebook (Cannot find "facebookConnectPlugin")

I am creating an application using Ionic 2 that will make some calls to the Facebook API. I followed the steps from the documentation and installed the cordova cordova-plugin-facebook4 plugin .

Now I am trying to authenticate the user, but to no avail. My login page:

import {Page} from 'ionic-framework/ionic';


@Page({
  templateUrl: 'build/pages/page1/page1.html',
})
export class Page1 {
  login() {
    facebookConnectPlugin.login(
      ['email'],
      response => {
        console.log(response);
      },
      error => {
        console.log(error);
      }
    );
  }
}

When I launch the application with:

ionic serve

I get the following error in the terminal:

enter image description here

When I click on the login button, I get the following error in the console:

enter image description here

And when I try to create an application to run on a real device, I get the following error in the console:

enter image description here

I think I need to import the plugin so that it can use, but how?

+4
3

.

- npm install ionic-native --save facebook import {Facebook} from 'ionic-native '

facebook

  fblogin(){
    this.platform.ready().then(() => {
      Facebook.login(["email"]).then((result) => {
        console.log(result)
       })
    })
  }

+3

facebookConnectPlugin Cordova , , . jeduan repo -, , .

Cannot find name facebookConnectPlugin, TypeScript. Transpiling JS.

, . , (. ). Facebook ( developer.facebook.com)

ionic plugin add cordova-plugin-facebook4 --variable APP_ID="123456789" --variable APP_NAME="myApplication"

Android - Facebook. OSX, keyhash :

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

+2

,

. facebook, cordova, . .

Detailed instructions are here http://tphangout.com/?p=204

Hope this helps you, thanks.

+1
source

All Articles