Facebook login native promise available but not working [solved]

Hi , i’m facing a little issue with facebook login plugin (with a lot of another plugin too)
so i installed ionic-native and the plugin with $ ionic plugin add cordova-plugin-facebook4

and tried to run it into my app like this

    this.platform.ready().then(() => {
      Facebook.login(["email, public_profile"]).then((result) => {
        this.rootRef.$authWithOAuthToken("facebook", result.access_token).then((user) => {

when i click the button , i have error message

Native: tried calling Facebook.login, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

the plugin dont work in simulator or devices , anyone installed facebook plugin in his app?

I have the same problem , I think this is because using the ionic 2 -ts , the plugin cord -plugin- facebook4 not yet there is a typescript .
Can anyone help us?

tested =) works fine with babel ionic version , maybe something with typescript, all plugin works fine with babel version but typescript …

exactly , also made ​​a new test, the compiler complains that there is not facebookConnectPlugin but when compiled and executed it works.

tests this excemplo https://github.com/fuffenz/ionic2-native-facebook-login

I think the issue is indeed that you don’t have the typing file for the plugin. However, you might want to give ionic-native a try, there seems to be a plugin for facebook: https://github.com/driftyco/ionic-native/tree/master/src/plugins

I could not use the ionic -native and cordova-plugin-facebook4 , you would have some practical example to see how I use?

i’m using ionic-native in my case , as you can see Facebook.login , instead of the term provided by the plugin itself

Unfortunately not, I’ve never used it myself (yet) :\

You might want to check out the new Ionic User offering which handles Facebook login I think.

I’m trying to USE IT with typescript but without success :frowning:
I get THAT Message
ORIGINAL EXCEPTION: TypeError : this.facebook.login is not a function

thanks richard , i’m using firebase and geofire , firebase facebook login works perfectly , but i was looking for a native solution. and ionic.io dont provide a solution like geofire , so i prefer to keep using firebase for the moment . i will look at ionic.io user .

please paste , what you are doing

import {Page, Platform} from 'ionic-angular';
import {Facebook} from 'ionic-native';

    templateUrl: 'build/pages/login/login.html',
    providers: [Facebook]
export class Login {
    public platform;
    public facebook;
    constructor(platform: Platform, facebook: Facebook ) {
        this.platform = platform;
        this.facebook = facebook;
     login() {
        if(this.platform.is('cordova')) {
            this.facebook.login([ 'email, publish_actions' ], (success) => {
                },(err) => {
            } else {
                console.log("Please run me on a device");

try Facebook.login instead of this.facebook.login and you can delete facebook: facebook from dependency injection , and this.facebook = facebook , also public facebook

Partially worked for me , now he is presenting this error in xcode console , you already have seen something?

Mar 10 13:15:53 Developers-Mac ToNaBalada[6348]: Starting login Mar 10 13:15:53 Developers-Mac ToNaBalada[6348]: *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> Permissions should each be specified in separate string values in the array.

its about the facebook permissions , as it say , you should put each permissions into separate string in the array ,try to just take email for testing , i will also test

Thanks for the help , I did as you said and I could make it work
Thank you.

should works properly now , for me its working , the issue was on the permission , former cordova plugin for facebook was letting us to pass permission into one string , but now we need to separate them, so thank you pointing this out


Hey - do you mind confirming what you did to fix this?