本文整理汇总了TypeScript中@ionic-native/facebook.Facebook类的典型用法代码示例。如果您正苦于以下问题:TypeScript Facebook类的具体用法?TypeScript Facebook怎么用?TypeScript Facebook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Facebook类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: signOut
signOut() : firebase.Promise<any> {
if (this.angularFireAuth.auth.currentUser.providerData.length) {
for (var i = 0; i < this.angularFireAuth.auth.currentUser.providerData.length; i++) {
var provider = this.angularFireAuth.auth.currentUser.providerData[i];
if (provider.providerId == firebase.auth.GoogleAuthProvider.PROVIDER_ID) { // Se for o gooogle
// o disconnect limpa o oAuth token e tambem esquece qual conta foi selecionada para o login
return this.googlePlus.disconnect()
.then(() => {
return this.signOutFirebase();
});
} else if (provider.providerId == firebase.auth.FacebookAuthProvider.PROVIDER_ID) { // Se for facebook
return this.facebook.logout()
.then(() => {
return this.signOutFirebase();
})
} else if (provider.providerId == firebase.auth.TwitterAuthProvider.PROVIDER_ID) { // Se for twitter
return this.twitter.logout()
.then(() => {
return this.signOutFirebase();
})
}
}
}
return this.signOutFirebase();
}
示例2: Promise
return new Promise((resolve, reject) => {
if (this.plt.is('cordova')) {
this.facebook.login(["email"])
.then(loginResponse => {
let credential = firebase.auth.FacebookAuthProvider.credential(loginResponse.authResponse.accessToken)
this.afAuth.auth.signInAndRetrieveDataWithCredential(credential)
.then(info => {
resolve(info)
this.loginJobs();
})
.catch(err => {
reject(err)
alert(err)
})
})
.catch(err => {
reject(err)
alert(err)
})
} else {
this.afAuth.auth
.signInWithPopup(new firebase.auth.FacebookAuthProvider())
.then(info => {
resolve(info)
this.loginJobs();
})
.catch(err => {
reject(err)
alert(err)
})
}
})
示例3: Promise
return new Promise((resolve, reject) => {
if (this.platform.is('cordova')) {
this.facebook.login(['email', 'public_profile', 'user_friends'])
.then((facebookData: FacebookLoginResponse) => {
const loading = this.loadingCtrl.create({
content: 'Por favor, aguarde...'
});
loading.present();
const credential = firebase.auth.FacebookAuthProvider
.credential(facebookData.authResponse.accessToken);
firebase.auth().signInWithCredential(credential).then((firebaseData) => {
setTimeout(() => {
this.functions.post('users', {
facebook: facebookData.authResponse.userID
}).subscribe((response) => {
loading.dismiss();
resolve();
}, (error) => {
loading.dismiss();
reject(error);
});
}, 800);
});
}, (error) => {
resolve(error);
});
}
});
示例4: signInWithFacebook
signInWithFacebook() {
return this.facebook.login(['public_profile', 'email'])
.then((res: FacebookLoginResponse) => {
//https://developers.facebook.com/docs/graph-api/reference/user
//Ao logar com o facebook o profile do usuario ĂŠ automaticamente atualizado.
return this.angularFireAuth.auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(res.authResponse.accessToken));
});
}
示例5: logout
logout(){
this.fb.logout().then((res) =>
console.log('Logged into Facebook!', res)).catch(e =>
console.log('Error logging into Facebook', e));
this.googleplus.logout().then((res) =>
console.log('logged out of google',res)).catch(err => console.error(err));
localStorage.clear();
this.navCtrl.setRoot(LoginPage);
}
示例6: nativeFacebookLogin
async nativeFacebookLogin(): Promise<void> {
try {
const response = await this.facebook.login(["email", "public_profile"]);
const facebookCredential = firebase.auth.FacebookAuthProvider.credential(
response.authResponse.accessToken
);
const firebaseUser = await firebase
.auth()
.signInWithCredential(facebookCredential);
return await this.updateUserData(firebaseUser);
} catch (err) {
console.log(err);
}
}
示例7: login
login(): void {
this.loading.present();
this.Facebook.login(['public_profile']).then((response) => {
this.getProfile();
},
(err) => {
console.log(err);
let alert = this.alertCtrl.create({
title: 'Oops!',
subTitle: 'Something went wrong, please try again later.',
buttons: ['Ok']
});
this.loading.dismiss();
alert.present();
});
}
示例8:
return Observable.create((observer) => {
if (this.platform.is('cordova')) {
this.facebook.login(['email', 'public_profile', 'user_friends'])
.then((facebookData: FacebookLoginResponse) => {
const credential = firebase.auth.FacebookAuthProvider
.credential(facebookData.authResponse.accessToken);
firebase.auth().currentUser.linkWithCredential(credential).then((user) => {
this.data.update(`users/${user.uid}`, {
facebook: facebookData.authResponse.userID
}).then(() => {
observer.next();
}, (error) => {
observer.error(error);
});
});
});
}
});
示例9: login
login(): void {
this.facebook.login(['public_profile']).then((response) => {
this.getProfile();
}, (err) => {
this.getProfile();
});
}
示例10: resolve
this.http.post(this.storageProvider.serverAddress+"/logout",JSON.stringify({version:this.storageProvider.version}),{headers: headers}).map(res=>res.json()).subscribe((res)=>{
this.fb.logout().then((result)=>{
resolve(res);
},(err)=>{
resolve(res);
});
},(err)=>{