Javascript 爱奥尼亚2中的本机facebook登录

Javascript 爱奥尼亚2中的本机facebook登录,javascript,facebook,cordova,angular,ionic2,Javascript,Facebook,Cordova,Angular,Ionic2,我正在尝试使用cordova-plugin-facebook4在爱奥尼亚2项目中使用本机FB登录。我正在一个没有安装Facebook应用程序的模拟器上测试我的应用程序。我也在应用程序浏览器插件中安装了cordova。但是当我运行应用程序时,我得到了一个错误 未捕获(承诺中):TypeError:无法读取的属性“apply” 未定义:无法读取callCordovaPlugin中未定义的属性 我的实现灵感来自 我添加了declare const facebookConnectPlugin:any;'

我正在尝试使用cordova-plugin-facebook4在爱奥尼亚2项目中使用本机FB登录。我正在一个没有安装Facebook应用程序的模拟器上测试我的应用程序。我也在应用程序浏览器插件中安装了cordova。但是当我运行应用程序时,我得到了一个错误

未捕获(承诺中):TypeError:无法读取的属性“apply” 未定义:无法读取callCordovaPlugin中未定义的属性

我的实现灵感来自 我添加了declare const facebookConnectPlugin:any;'到我的.d.ts文件 还是不行? 帮帮我

这是myhome.ts的代码片段

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Facebook } from '@ionic-native/facebook';

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'
})

export class HomePage {
    FB_APP_ID: number = xxxxxxxxxxxx;
    constructor(public navCtrl: NavController, private fb: Facebook) {
        this.fb.browserInit(this.FB_APP_ID, "v2.8");
    }
    doFbLogin() {
        let permissions = new Array();
        let nav = this.navCtrl;
        //the permissions your facebook app needs from the user
        permissions = ["public_profile"];
        this.fb.login(permissions).then(function(response) {
            let userId = response.authResponse.userID;
            let params = new Array();
            //Getting name and gender properties
            this.fb.api("/" + userId + "/me?fields=name,gender", params).then(function(user) {
                user.picture = "https://graph.facebook.com/" + userId + "/picture?type=large";
                //now we have the users info, let's save it in the NativeStorage
                alert(JSON.stringify(user));
            })
        }, function(error) {
            alert(JSON.stringify(error));
        });
    }
}
package.json的内容

{
  "name": "Filanthro",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.0.0",
    "@angular/compiler": "4.0.0",
    "@angular/compiler-cli": "4.0.0",
    "@angular/core": "4.0.0",
    "@angular/forms": "4.0.0",
    "@angular/http": "4.0.0",
    "@angular/platform-browser": "4.0.0",
    "@angular/platform-browser-dynamic": "4.0.0",
    "@ionic-native/core": "3.4.2",
    "@ionic-native/facebook": "^3.5.0",
    "@ionic-native/in-app-browser": "^3.5.0",
    "@ionic-native/splash-screen": "3.4.2",
    "@ionic-native/status-bar": "3.4.2",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.0.1",
    "ionicons": "3.0.0",
    "rxjs": "5.1.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.0",
    "typescript": "~2.2.1"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-statusbar",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "FaB: An Ionic project"
}
app.module.ts的内容

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { Facebook }  from '@ionic-native/facebook';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    Facebook,
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

这是emulator出现某些问题的结果。它在真实设备上运行良好

这是emulator出现某些问题的结果。它在真实设备上运行良好

请参见:我已将Facebook包括在app.module.ts中,并已将其包括在提供商中。我已经解决了这三个问题,但在我的案例中似乎没有一个问题。请看:我已经将Facebook包括在app.module.ts中,并将其包括在提供商中。我已经处理了这三个问题,但在我的案例中似乎没有一个是存在的。