简体   繁体   English

使用Firebase在Ionic应用程序中注销Facebook

[英]Log out of Facebook in Ionic app using Firebase

I am using single-sign on with Facebook in my application and have been attempting to logout but have been unsuccessful with the posted solutions. 我在应用程序中使用Facebook单点登录,并一直尝试注销,但发布的解决方案未成功。 I am currently getting an error stating cannot read property of "logout". 我目前收到一条错误消息,指出无法读取“注销”的属性。 Thanks! 谢谢!

 angular.module('starter.controllers', [])

    .controller('AppCtrl', function($scope, $ionicModal, $timeout,$state) {

      var ref = new Firebase("https://example.firebaseio.com");

    $scope.loginFacebook = function(){

      if(ionic.Platform.isWebView()){

        $cordovaFacebook.login(["public_profile", "email"]).then(function(success){

          console.log(success);

          ref.authWithOAuthToken("facebook", success.authResponse.accessToken, function(error, authData) {
            if (error) {
              console.log('Firebase login failed!', error);
            } else {
              console.log('Authenticated successfully with payload:', authData);

               return $state.go('app.gyms');
            }
          });

        }, function(error){
          console.log(error);
        });        

      }
      else {

        ref.authWithOAuthPopup("facebook", function(error, authData) {
          if (error) {
            console.log("Login Failed!", error);
          } else {
            console.log("Authenticated successfully with payload:", authData);
            console.log("Username:" + authData.facebook.displayName);
            console.log("Profile Image:" + authData.facebook.profileImageURL);
            $scope.displayName = authData.facebook.displayName;
            $scope.profileImageURL = authData.facebook.profileImageURL;
             $scope.modal.hide();
                     $scope.isLoggedIn = function(){
        return true;
      };
      $scope.isLoggedIn();
          }
        });

      }

    };

     $scope.logOut = function() {
         ref.unauth();
          return $state.go('app.gyms');
      };
    })

I think you are looking for to call authData.unAuth() 我认为您正在寻找致电authData.unAuth()

Let me know if that doesn't help. 让我知道这是否无济于事。

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM