I am working on an IONIC 3 application, and trying to make login using Facebook. I have made a button, where I trigger a registerUser()
function on click
event. I have perfectly created app over Facebook developer console, and installed Facebook plugin through this link. I followed the documentation, and it worked perfectly.
I have imported import { Facebook } from '@ionic-native/facebook/ngx';
in the app.module.ts
file, and assigned Facebook
in the Providers as well. And also Imported import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook/ngx';
in the signup.ts
.
The problem is, this app was built with IONIC 3, and now when I flip to the documentation of IONIC 3, and search for facebook, upon clicking the facebook link, I get redirected to this page which I followed to install the plugins etc. When I run the app, the function registerUser()
is triggered and it returns an error which says,
ERROR TypeError: Object(...) is not a function
at Facebook.login (index.js:62)
at SignupPage.webpackJsonp.186.SignupPage.registerUser (signup.ts:83)
at Object.eval [as handleEvent] (SignupPage.html:78)
at handleEvent (core.js:13589)
at callWithDebugContext (core.js:15098)
at Object.debugHandleEvent [as handleEvent] (core.js:14685)
at dispatchEvent (core.js:10004)
at core.js:10629
at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
at t.invokeTask (polyfills.js:3)
The Facebook Code
export class SignupPage {
constructor(
public facebook: Facebook
) {}
//Register User
registerUser() {
this.facebook.login(['public_profile', 'user_friends', 'email'])
.then((res: FacebookLoginResponse) => {
console.log('Logged into Facebook!', res)
})
.catch(e => {
console.log('Error logging into Facebook', e)
});
}
}
The IONIC Button
<ion-item id="border-none">
<button ion-button block id="login-button" (click)="registerUser()">Create Account</button>
</ion-item>
I have searched for different solutions, even here, but nothing helped out.