本文整理匯總了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)=>{