Closed milagic closed 6 years ago
:+1: Same issue Here.
+1
do you add Facebook provider in app.module.ts??
import { Facebook } from '@ionic-native/facebook'; ..... providers: [ ... [Facebook] ]
@mokrea Can you actually show what are you importing?
import { Facebook } from '@ionic-native/facebook';
That's exactly what I did, but it doesn't work.
check this: https://github.com/mokrea/ionic2-facebook-login-example (uploaded and tested today and working.. try create a new project and change app.modules.js and home.js to test) https://github.com/danyalzia/ionic2-facebook-play (it's the source code i used, there are much more examples here)
@mokrea This worked for me thanks. I also had to go through that android facebook login set up (https://developers.facebook.com/docs/facebook-login/android). I had to set the package name, default activity class name, for which i just appended 'MainActivity' onto my package name. Then I also had to set the development key hash using keytool. Enabling single sign on on that facebook login android page was the last thing i needed before my app was able to successfully login with facebook in development.
@txavier can you show sample code ? Do you use browserInit before login() or just login()?
Hey @gigeos , I am using Ionic 2. I added a login button to my home page and just included this code. Here you go:
`loginClick() { this.fb.login(['public_profile']) .then((res: FacebookLoginResponse) => { let userId = res.authResponse.userID; let accessToken = res.authResponse.accessToken; let expiresIn = res.authResponse.expiresIn; let session_key = res.authResponse.session_key;
console.log('Logged into Facebook! ' + userId, res);
this.navCtrl.setRoot(AssignedClassesPage);
})`
Thanks @txavier but I don't understand I do it and I have a message in Facebook popin which say: You are not logged. Please login.
Did you get it ?
@gigeos You mean this one?
I get this exact problem. @aborovsky
@carvemerson It connected with specified Facebook OAuth app's configuration, for sure. I have 2 app on developer.facebook.com and same code (calling cordova-plugin-facebook4's login) cause to different result: success with one AppId and fail with another one.
Right now we are investigating. Suppose, cordova-plugin-facebook4 require for OAuth implicit grant flow. But why it (implicit grant) should be allowed for my Facebook OAuth app?
@aborovsky Yes that's! I forgot what was the reason but it seems to me that was due to a configuration issue on Facebook Developper
Hello guys, I sove my problem only removing and adding the platform. So, I did:
ionic cordova platform rm android
ionic cordova platform add android
and now it's works for me.
@txavier as mentioned in your comment, i've already set up app in developer console. Also in app.module.ts I've made required changes.
still it throws an error without any error code or error description.
these are my plugin details : cordova-plugin-device 1.1.4 "Device" cordova-plugin-facebook4 1.9.1 "Facebook Connect" cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview" cordova-plugin-splashscreen 4.0.3 "Splashscreen" cordova-plugin-whitelist 1.3.1 "Whitelist" ionic-plugin-keyboard 2.2.1 "Keyboard"
this is my home.ts code
fbLogin() { alert("login facebook"); this.facebook.login(['email', 'public_profile']).then((res: FacebookLoginResponse) => { this.access = JSON.stringify(res); alert("success facebook"); this.facebook.api('me?fields=id,name,email,first_name,picture.width(720).height(720).as(picture_large)', []).then(profile => { alert("data facebook"); this.response = JSON.stringify(profile); }); }, error=> { alert("error facebook");// returns only {} this.error = JSON.stringify(error); }); // this.facebook.logEvent(this.fb.EVENTS.EVENT_NAME_ADDED_TO_CART); }
It's not working.
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">
This question is one year old almost, I close it for inactivity. Furthermore I could confirm I don't face this problem with my app in production.
For support questions plz use other channels like Stackoverflow or Ionic forum
@aborovsky and @gigeos You should "add platform" on your facebook console and insert the Google Play package name, if you're trying to deploy your application in a android device.
The package name is the "widgetd id attribute" in second line of your config.xml file. like this:
You need to add an Android platform from your facebook app basic settings page and setup. Just simply follow the steps from here to create release key hashes: https://developers.facebook.com/docs/facebook-login/android
It solved the same problem for me
Using Ionic 2 to create a login page, but I'm unable to understand where the issue is since the login API fails silently (without any error message). Env: Android.
this.fb.login(['public_profile']) .then((res: FacebookLoginResponse) => { console.log('Logged into Facebook!', res); // Store To App User Data. this.nav.setRoot(HomePage); }) .catch(e => console.error('Error logging into Facebook',e));
This results in -> Error logging into Facebook Object {}