使用Firebase在Ionic应用程序中退出Facebook

时间:2016-01-12 03:38:05

标签: angularjs facebook ionic-framework

我在我的应用程序中使用Facebook进行单点登录,并且一直在尝试注销,但是已经发布的解决方案失败了。我目前收到错误,说明无法读取“注销”的属性。谢谢!

 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');
      };
    })

1 个答案:

答案 0 :(得分:0)

我认为您正在寻找致电authData.unAuth()

如果这没有帮助,请告诉我。

Source