PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 16, 2022

[FIXED] Why 'The method FB.login can no longer be called from http pages.' does appear in my Ionic4 app?

 July 16, 2022     facebook-authentication, facebook-login, firebase, ionic4     No comments   

Issue

I'm trying to setup the facebook login in my Ionic 4 application but it does not work when I use the cordova method. The console displays two errors :

The method FB.login can no longer be called from http pages.

FB.login() called before FB.init().

The web method is fully working.

facebookCordova() {
    this.fb.login(['email']).then(
      (response) => {
        const facebookCredential = firebase.auth.FacebookAuthProvider.credential(response.authResponse.accessToken);
        firebase.auth().signInWithCredential(facebookCredential)
        .then((success) => {
            console.log('Info Facebook: ' + JSON.stringify(success));
        }).catch((error) => {
            console.log('Erreur: ' + JSON.stringify(error));
        });
      }).catch((error) => { console.log(error); });
  }

The output expected is the user informations get in "success". Thanks for your help


Solution

The message "The method FB.login can no longer be called from http pages." still showing in console for me, but the message "FB.login() called before FB.init()" disappeared and the login functionality started to work after I did the following:

1 - Removed the platform

ionic cordova platform rm browser

2 - Removed Facebook plugin

ionic cordova plugin rm cordova-plugin-facebook4 --variable APP_ID="123456789" --variable APP_NAME="BlahBlahBlah"

3 - Added Facebook plugin with --save (I think the --save parameter is the solution, and it is not mentioned in the documentation https://ionicframework.com/docs/native/facebook )

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

4 - Added the platform again

ionic cordova platform add browser



Answered By - Ronaldo Zoccaratto de Souza
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing