Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Ion-toggle not changing states after user cancels option

$
0
0

@rolinger wrote:

I have a toggle button that triggers a Facebook login for the user. It pretty much all works. Except that when the user cancels the login, I see the console message say "user cancelled login" and then reset the ion-toggle back to false/off - but it won't change states but I do see the console.log message "In DisableFB" so I know the function/function call are working. If I leave the page and come back, it then shows off.

  <ion-toggle id="settings_FB" ng-model="fbItem.checked" ng-change="setFB()">
    Facebook Enabled:
  </ion-toggle>

  $scope.disableFB = function () {
    $scope.fbItem = {checked : false } ;
    console.log("In DisableFB") ;
  }

  $scope.setFB = function() {
    if ($scope.fbItem.checked == true) {
      alert("After logging into FB, you may need to set FB permissions to allow the app to interact with your FB page.") ;
      var fbLoginSuccess = function (userData) {
        ...some code ...
        facebookConnectPlugin.getAccessToken(function(token) {
       ....some code....
        }, function(err) {
          $scope.disableFB() ;
          console.log("FB: error retrieving token: " + err);
        });
      }

      facebookConnectPlugin.getLoginStatus(
        function(response) {
          if (response.status == "connected") {
             ...some code...
          } else {
            facebookConnectPlugin.login(["public_profile"],
              fbLoginSuccess,
              function (error) {
                 $scope.disableFB() ;  // *** this is the line that fires when user cancels.***
                 console.log(error) ;
              }
            );
          }
        },function(error) {
          $scope.disableFB() ;
          console.log(response) ;
        }
  );
} else {
  facebookConnectPlugin.logout(
    function(response) {
      console.log("FB Logged out") ;
      ...some code....
      $scope.disableFB() ;
    },
    function(error) {
      console.log("FB Logout Error: "+ error.message) ;
      ...some code...
      $scope.disableFB() ;
    }
  ) ;
}

}

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>