am trying to do facebook login in ionic 2 app, but got this error while building my app. help me to solve this.
[13:17:52] transpile started ... [13:17:58] typescript: D:/royalworkspace/newfblogin/node_modules/@ionic-native/facebook/index.d.ts, line: 1 Module '"D:/royalworkspace/newfblogin/node_modules/@ionic-native/core/index"' has no exported member 'IonicNativePlugin'.
L1: import { IonicNativePlugin } from '@ionic-native/core'; L2: export interface FacebookLoginResponse {
-- Home.ts --
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, private facebook: Facebook ) {
}
Login(){
this.facebook.login(['email']).then((Response) =>{
alert('loged in');
alert(JSON.stringify(Response.authResponse));
},(error) => {
alert(error);
})
}
LoginDetails(){
this.facebook.getLoginStatus().then((response) => {
if (response.status == "connected") {
this.facebook.api('/' + response.authResponse.userID + '?fields=id,name,gender', []).then((response) =>{
alert(JSON.stringify(response));
}, (error) =>{
alert(error);
})
}
else{
alert('not loged in');
}
})
}
Logout(){
this.facebook.logout().then((Response) => {
alert(JSON.stringify(Response));
}, (error) =>{
alert(error);
})
}
}
-- home.html --
<ion-content padding>
<button ion-button outline (click)="Login()">Login</button>
<button ion-button outline (click)="LoginDetails()">Login Details</button>
<button ion-button outline (click)="Logout()">Logout</button>
</ion-content>
-- app.module --
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, FacebookLoginResponse } 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: [
StatusBar,
SplashScreen,Facebook,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
IonicNativePlugin was added in newer version of ionic-native/core, so I had to uninstall this one and install the newest one which is 3.6.1, and now plugin got exported and everything works fine.
Save yourselves with this.
npm uninstall --save @ionic-native/core
npm install --save @ionic-native/core@latest
Did run into same problem and got it working by upgrading @ionic-native/core
dependency to latest version (at this time to 3.6.1
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With