Created
October 19, 2016 14:55
-
-
Save NekoTashi/48bcf10e08adb2f04dc4eab7bbb1283e to your computer and use it in GitHub Desktop.
Snippet de Ionic para hacer login con FB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('starter', ['ionic']) | |
| .run(function($ionicPlatform) { | |
| $ionicPlatform.ready(function() { | |
| if (window.cordova && window.cordova.plugins.Keyboard) { | |
| cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); | |
| cordova.plugins.Keyboard.disableScroll(true); | |
| } | |
| if (window.StatusBar) { | |
| StatusBar.styleDefault(); | |
| } | |
| }); | |
| }).controller('LoginController', ['$scope', function($scope) { | |
| $scope.userData = 'None'; | |
| $scope.token = 'None'; | |
| $scope.fbLogin = function() { | |
| facebookConnectPlugin.login(['public_profile'], successFBLogin, errorFBLogin); | |
| }; | |
| $scope.fbLogout = function() { | |
| facebookConnectPlugin.logout(function() { | |
| alert('logged out'); | |
| }, errorFBLogin); | |
| }; | |
| var successFBLogin = function(userData) { | |
| $scope.userData = userData; | |
| console.log("UserInfo: ", userData); | |
| facebookConnectPlugin.getAccessToken(function(token) { | |
| $scope.token = token; | |
| console.log("Token: " + token); | |
| }); | |
| }; | |
| var errorFBLogin = function(error) { | |
| console.error(error); | |
| }; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment