Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. `ionic plugin add cordova-plugin-facebook4 --variable APP_ID="123456789" --variable APP_NAME="myApplication"`
  2.  
  3. Facebook.login(['email']).then( (response) => {
  4. let facebookCredential = firebase.auth.FacebookAuthProvider
  5. .credential(response.authResponse.accessToken);
  6. var that = this;
  7. firebase.auth().signInWithCredential(facebookCredential)
  8. .then((success) => {
  9. that.nav.setRoot(HomePage);
  10. })
  11. .catch((error) => {
  12. console.log("Firebase failure: " + JSON.stringify(error));
  13. });
  14.  
  15. }).catch((error) => { console.log(error) });
  16.  
  17. //facebook functions
  18.  
  19.  
  20. getDetailsFacebook() {
  21. var that=this;
  22. Facebook.getLoginStatus().then((response)=> {
  23. if (response.status == 'connected') {
  24. Facebook.api('/' + response.authResponse.userID + '?fields=id,name,gender', []).then((response)=> {
  25. //alert(JSON.stringify(response));
  26. that.uid = response.id;
  27. that.name=response.name;
  28. that.photo = "http://graph.facebook.com/"+that.uid+"/picture?type=large";
  29. that.user=new User(that.uid,that.fireUid,that.name, that.photo);
  30. that.profileData.setProfileData(that.user); // to create class for that
  31.  
  32. //that.profileData.setProfile(that.uid,that.name,that.photo);
  33. //console.log("id:"+this.uid+this.name+this.photo);
  34. }, (error)=> {
  35. alert(error);
  36. })
  37. }
  38. else {
  39. alert('Not Logged in');
  40. }
  41. })
  42.  
  43. logOutFacebook(){
  44. Facebook.logout().then((response)=>
  45. {
  46. this.navCtrl.push(LoginPage);
  47. alert(JSON.stringify(response));
  48. },(error)=>{
  49. alert(error);
  50. })
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement