當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ionic-native.Facebook類代碼示例

本文整理匯總了TypeScript中ionic-native.Facebook的典型用法代碼示例。如果您正苦於以下問題:TypeScript Facebook類的具體用法?TypeScript Facebook怎麽用?TypeScript Facebook使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Facebook類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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) {
開發者ID:RemaxThailand,項目名稱:RemaxMobile,代碼行數:26,代碼來源:login.ts

示例2:

 .then((res:any) => {
   if (res.status === 'connected') {
     return Facebook.logout();
   } else {
     return Promise.resolve();
   }
 })
開發者ID:hack4change,項目名稱:hambasafe-client,代碼行數:7,代碼來源:auth.actions.ts

示例3: 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);
   }
 })
開發者ID:hack4change,項目名稱:hambasafe-client,代碼行數:25,代碼來源:auth.actions.ts

示例4: 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);
             }
         );
     }
 });
開發者ID:rdlabo,項目名稱:FacebookLogin-Ionic2-browser,代碼行數:25,代碼來源:facebook.ts

示例5: getDeviceFacebookProfile

  getDeviceFacebookProfile() : any { 
    var respJson : any = {
      'isRegistered' : false,
    }
    return Facebook.getLoginStatus().then((response)=> {
      console.log('Status');
      console.log(JSON.stringify(response));
      if (response.status !== 'connected') {
        this.setAnonymous()
      } else {
        _.merge(respJson, _.pick(response.authResponse, ['accessToken' , 'userID']));
        respJson.fbId = respJson.userID;
        respJson.userID = undefined;
        //TODO: Remove
        console.log(response);
      }
      return Promise.resolve();
    }).then((res)=> {
      return Facebook.api('/me?fields=first_name,last_name,birthday,gender,email,picture', [])
    })
    .then((apiResponse: any) => {
      console.log(apiResponse);
      _.merge(respJson,  _.pick(apiResponse, [
        'first_name',
        'last_name',
        'birthday',
        'gender',
        'email',
      ]));
      respJson.picture = apiResponse.picture.data.url;
      respJson.isSilhouette = apiResponse.picture.data.is_silhouette;
      return Promise.resolve(respJson);
    });

  }
開發者ID:hack4change,項目名稱:hambasafe-client,代碼行數:35,代碼來源:auth.actions.ts

示例6: 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;

        });

    }
開發者ID:maxamillion32,項目名稱:Fittist,代碼行數:34,代碼來源:AuthService.ts

示例7: login

 static login(successCallback, errorCallback) {
     Facebook.login(['user_friends']).then(response => {
         successCallback(response.authResponse);
     }, error => {
         errorCallback(error.errorMessage);
     })
 }
開發者ID:in-dex,項目名稱:ionic2-foodApp,代碼行數:7,代碼來源:facebook-login.ts

示例8: authDevice

 authDevice() : Promise<any> {
   // Set loading state.
   console.log('dispatching auth Device');
   return Facebook.getLoginStatus()
   .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);
     }
   })
   .then((res) => {
     console.log('call parse Login');
     console.log(res);
     return this.parseManager.deviceLogin(res);
   })
 }
開發者ID:hack4change,項目名稱:hambasafe-client,代碼行數:35,代碼來源:auth.actions.ts

示例9: facebookLogin

 facebookLogin(successCallback,errorCallback){
   Facebook.login(['user_friends']).then(response => {
     console.log(response);
     successCallback(response.authResponse);
   }, error => {
     errorCallback(error);
   });
 }
開發者ID:guihendias,項目名稱:iniciacao-cientifica,代碼行數:8,代碼來源:UtilServices.ts

示例10:

      .then(() => {
        Facebook.login(['email'])
          .then((result: FacebookLoginResponse) => {

            console.log("Facebook success: " + JSON.stringify(result));
            //   });
          })
          .catch((err) => { console.log('err accured', err) })
      })
開發者ID:Muhammad-MuZzammil,項目名稱:Ionic2-Projects,代碼行數:9,代碼來源:home.ts


注:本文中的ionic-native.Facebook類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。