0

Ich versuche, Firebase-Authentifizierung mit Angularfire signInWithCredential-Methode für meine Ionic App zu implementieren. Da ich das Firebase 3.x SDK verwende, werden die Methoden signInWithRedirect und signInWithPopup auf Mobilgeräten noch nicht unterstützt. Also benutze ich das Plugin ngCordovaOauth.Umgang mit Facebook/Google Login mit ngCordovaOauth in Ionic + Firebase

var ref = firebase.database().ref().child("users"); 
$scope.users = $firebaseArray(ref); 
$cordovaOauth.facebook("//removed_client_id", [ "public_profile", "email"]).then(function(result) { 
    var credentials = firebase.auth.FacebookAuthProvider.credential(result.access_token); 
    $scope.authObj.$signInWithCredential(credentials).then(function(authData) { 
    var existUser = $scope.users.$getRecord(authData.uid); 
    if(existUser == null){ 
     $scope.user = { 
     uid: authData.uid, 
     displayName: authData.displayName, 
     avatar: authData.photoURL, 
     email: authData.email, 
     contact: "0000000000", 
     provider: "facebook" 
     } 
     firebase.database().ref("users/" + authData.uid).set($scope.user); 
    } 
    $rootScope.result = authData; 
    $state.go("menu.home"); 
    }, function(error) { 
    console.error("ERROR: " + error); 
    }); 
}, function(error) { 
    console.log("ERROR: " + error); 
}); 

Das Problem, das ich mit Blick auf bin ist, ich habe keine Ahnung, was die Struktur der ‚authdata‘ wie ich keine Unterlagen für das gleiche finden. Mit sigInWithPopup gibt firebase das Ergebnisobjekt zurück; Auf Inhalte wie 'result.user.uid', 'result.user.displayName' oder 'result.user.email' kann zugegriffen werden. Wie kann ich dasselbe erreichen, wenn ich versuche, das Benutzerprofil zu speichern, wenn er sich das erste Mal anmeldet? Irgendeine Hilfe? Ich teste auf Android-Gerät. Vielen Dank!

Antwort