Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `ionic plugin add cordova-plugin-facebook4 --variable APP_ID="123456789" --variable APP_NAME="myApplication"`
- Facebook.login(['email']).then( (response) => {
- let facebookCredential = firebase.auth.FacebookAuthProvider
- .credential(response.authResponse.accessToken);
- var that = this;
- firebase.auth().signInWithCredential(facebookCredential)
- .then((success) => {
- that.nav.setRoot(HomePage);
- })
- .catch((error) => {
- console.log("Firebase failure: " + JSON.stringify(error));
- });
- }).catch((error) => { console.log(error) });
- //facebook functions
- getDetailsFacebook() {
- var that=this;
- Facebook.getLoginStatus().then((response)=> {
- if (response.status == 'connected') {
- Facebook.api('/' + response.authResponse.userID + '?fields=id,name,gender', []).then((response)=> {
- //alert(JSON.stringify(response));
- that.uid = response.id;
- that.name=response.name;
- that.photo = "http://graph.facebook.com/"+that.uid+"/picture?type=large";
- that.user=new User(that.uid,that.fireUid,that.name, that.photo);
- that.profileData.setProfileData(that.user); // to create class for that
- //that.profileData.setProfile(that.uid,that.name,that.photo);
- //console.log("id:"+this.uid+this.name+this.photo);
- }, (error)=> {
- alert(error);
- })
- }
- else {
- alert('Not Logged in');
- }
- })
- logOutFacebook(){
- Facebook.logout().then((response)=>
- {
- this.navCtrl.push(LoginPage);
- alert(JSON.stringify(response));
- },(error)=>{
- alert(error);
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement