2015-11-08 13 views
8

Tôi đang cố gắng để có được Parse.FacebookUtils.logIn để làm việc trên Ionic xem, tôi đã thành công có thể làm cho nó hoạt động khi tôi nhấn ionic phục vụ trong trình duyệt của tôi, nhưng vấn đề là khi tôi cố đăng nhập bằng trình giả lập Ionic View, về cơ bản cửa sổ xác thực Facebook không bật lên và tôi không biết tại sao.Phân tích Facebook Đăng nhập không hoạt động ở Ionic Xem

Tôi đi theo tài liệu này: https://www.parse.com/docs/js/guide#users-facebook-users

Tất cả mọi thứ hoạt động tốt trên trình duyệt chỉ cố gắng để làm cho nó làm việc trong Ionic xem.

Bất kỳ ý tưởng nào?

+0

Kiểm tra http://www.raywenderlich.com/44640/integrating-facebook-and-parse-tutorial-part-1 –

+0

Các vấn đề về facebook này trong chế độ xem mang tính biểu tượng có thể có vấn đề. Kiểm tra nhận xét trong https://github.com/driftyco/ionic-view-issues/issues/45 –

+0

@SomnathMuluk không giúp ích gì cả ở tất cả –

Trả lời

4

tôi đã lên trên Parse sdk với Ionic và bắt đầu sử dụng một plug-in khác sử dụng các tài liệu dưới đây:

http://ngcordova.com/docs/plugins/oauth/

https://github.com/nraboy/ng-cordova-facebook-example/blob/master/www/js/app.js

Dưới đây là đoạn code tôi đã làm để làm cho nó làm việc với Phân tích cú pháp:

$scope.fbLogin = function() { 
      var result; 
      $cordovaOauth.facebook('987971754588010', ['public_profile, user_birthday, email']).then(function(success) { 

       $http.get("https://graph.facebook.com/v2.2/me", { params: { access_token: success.access_token, fields: "id,name,birthday,last_name,first_name,email,gender,picture.type(large)", format: "json" }}).then(function(result) { 

        $localstorage.setObject('fbData', result.data); 

        var expiration_date = new Date(); 
        expiration_date.setSeconds(expiration_date.getSeconds() + success.expires_in); 
        expiration_date = expiration_date.toISOString(); 

        var facebookAuthData = { 
         "id": result.data.id, 
         "access_token": success.access_token, 
         "expiration_date": expiration_date 
        }; 

        Parse.FacebookUtils.logIn(facebookAuthData, { 
         success: function(user) { 
          if (!user.existed()) { 
           alert("User signed up and logged in through Facebook!"); 
           $scope.openModal(); 
          } else { 
           alert("User logged in through Facebook!"); 
           $scope.syncFbData(null); 
          } 
         }, 
         error: function(user, error) { 
          console.log('ERROR: ' + error); 
          var alertPopup = $ionicPopup.alert({ 
           title: 'Error de autenticación de usuario', 
           template: 'El usuario canceló autenticación con Facebook o no autorizó permisos. ' 
          }); 
         } 
        }); 
       }, function(error) { 
        console.log('ERROR: ' + error); 
        var alertPopup = $ionicPopup.alert({ 
         title: 'Error de conexión', 
         template: 'No se ha logrado establecer conexión con Facebook.' 
        }); 
       }); 
      }, function(error) { 
       console.log('ERROR: ' + error); 
       var alertPopup = $ionicPopup.alert({ 
        title: 'Error de conexión', 
        template: 'No se ha logrado establecer conexión con Facebook.' 
       }); 
      }); 
     }; 

     $scope.syncFbData = function (newUsername) { 
      var fbData = $localstorage.getObject('fbData') 
      var currentUser = Parse.User.current(); 
      if (newUsername) { 
       currentUser.set('username', newUsername); 
      } 
      currentUser.set('nombre', fbData.first_name); 
      currentUser.set('apellidos', fbData.last_name); 
      currentUser.set('email',fbData.email); 
      currentUser.set('fechaNacimiento', new Date(fbData.birthday)); 
      currentUser.set('imagenUrl',fbData.picture.data.url); 
      currentUser.set('genero',((fbData.gender === 'male') ? 'Hombre' : 'Mujer')); 
      currentUser.save(null, { 
       success: function (response) { 
        $scope.closeModal(); 
        $state.go('app.lista-cervezas'); 
       }, 
       error: function (response, error) { 
        console.log('ERROR: ' + error); 
        var alertPopup = $ionicPopup.alert({ 
         title: 'Nombre de usuario invalido', 
         template: 'El nombre de usuario ingresado ya se encuentra en uso!' 
        }); 
       } 
      }); 
     }; 
+0

FB SDK và SDK phân tích cú pháp dường như không hoạt động trong chế độ xem Ionic, emulater cũng như với tệp .apk –

Các vấn đề liên quan