本文整理汇总了TypeScript中ionic-native.Facebook.login方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Facebook.login方法的具体用法?TypeScript Facebook.login怎么用?TypeScript Facebook.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.Facebook
的用法示例。
在下文中一共展示了Facebook.login方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: login
static login(successCallback, errorCallback) {
Facebook.login(['user_friends']).then(response => {
successCallback(response.authResponse);
}, error => {
errorCallback(error.errorMessage);
})
}
示例2: Date
.then((res) => {
console.log('login Status');
console.log(res);
if(res.status !== 'connected') {
return Facebook.login(['public_profile', 'email']).then((res)=>{
console.log('post Login');
console.log(res);
var expDate = new Date(new Date().getTime() + res.authResponse.expiresIn * 1000 ).toISOString();
var authData = {
id: res.authResponse.userID,
access_token: res.authResponse.accessToken,
expiration_date: expDate
}
return Promise.resolve(authData);
})
} else {
var expDate = new Date(new Date().getTime() + res.authResponse.expiresIn * 1000 ).toISOString();
var authData = {
id: res.authResponse.userID,
access_token: res.authResponse.accessToken,
expiration_date: expDate
}
return Promise.resolve(authData);
}
})
示例3: Promise
return new Promise(function(resolve, reject) {
if (typeof cordova === "undefined") {
if( navigator.userAgent.match('CriOS') ){
alert("don't work chrome for iOS.you should use safari.");
} else {
console.log("start login");
FB.login(
function(response) {
console.log("login is resolve");
resolve(response);
},
{scope:'public_profile,user_friends,email'});
}
} else {
// using native
ngFacebook.login(['email','public_profile','user_friends']).then(
(response) => {
resolve(response);
},
(failed) => {
reject(failed);
}
);
}
});
示例4: loginWithFacebook
loginWithFacebook() {
return Facebook.login(['email', 'public_profile', 'user_friends']).then(response => {
console.log('Response: ' + JSON.stringify(response));
let creds = firebase.auth.FacebookAuthProvider
.credential(response.authResponse.accessToken)
let scope = new firebase.auth.FacebookAuthProvider()
console.log('Credentials: ' + JSON.stringify(creds));
let providerConfig = {
provider: AuthProviders.Facebook,
method: AuthMethods.OAuthToken,
remember: 'default',
scope: ['public_profile', 'email', 'user_friends']
}
this.af.auth.login(creds, providerConfig)
.then((authData) => {
/* Check if user exists, if not add user to database */
this.addUser(authData);
console.log("Firebase Success: " + JSON.stringify(authData));
});
}).catch(error => {
console.warn('Facebook Error: ' + JSON.stringify(error));
throw error;
});
}
示例5: if
Facebook.getLoginStatus().then((result) => {
//this.test = JSON.stringify(result);
if (result.status == 'unknown') {
//this.test = 'status : ' + result.status;
Facebook.login(["public_profile", "email"]).then((result) => {
//this.test = 'result : ' + JSON.stringify(result);
this.getFacebokInfo(result.authResponse.userID);
}, function (error) {
this.test = 'error : ' + error;
})
}
else if (result.status == 'connected') {
this.global.storage.get('member').then((member) => {
let json = JSON.parse(member);
if (member.type == 'facebook') {
this.getFacebokInfo(member.id);
}
else {
this.getFacebokInfo(result.authResponse.userID);
}
});
//this.test = 'status : ' + result.status;
//this.getFacebokInfo(result.authResponse.userID);
}
//alert(JSON.stringify(result));
}, function (error) {
示例6: facebookLogin
facebookLogin(successCallback,errorCallback){
Facebook.login(['user_friends']).then(response => {
console.log(response);
successCallback(response.authResponse);
}, error => {
errorCallback(error);
});
}
示例7:
.then(() => {
Facebook.login(['email'])
.then((result: FacebookLoginResponse) => {
console.log("Facebook success: " + JSON.stringify(result));
// });
})
.catch((err) => { console.log('err accured', err) })
})
示例8: login
login() {
if (this.platform.is('cordova')) {
Facebook.login(['email']).then(
response => this.angularFireAuth(response.authResponse.accessToken),
error => alert(`Facebook login failed. Error: ${JSON.stringify(error)}`)
);
}
else { // If we aren't in native environment where FB login works, use localStorage-stored value for token
this.angularFireAuth(localStorage.getItem('FACEBOOK_ACCESS_TOKEN'));
}
}
示例9: login
login() {
this.init();
Facebook.login( this.fbconnectvars.login_scope ).then( result => {
// we get back an auth response here, should save it or something
this.statusChangeCallback(result);
});
// return false; // so not to submit the form
}
示例10: loginF
loginF() {
var self = this;
Facebook.login(['email', 'public_profile']).then(
(response: FacebookLoginResponse) => {
Facebook.api('/me?fields=email', ['email', 'public_profile']).then((response) => {
console.log(response);
self.dataProviderService.login(response).subscribe(res => {
var user = res.json();
self.login(user, user.isNew);
});
});
},
(error: any) => console.error(error)
);
}