简体   繁体   English

ionic / firebase / cordova facebook身份验证

[英]ionic/firebase/cordova facebook Auth

I have a little problem with angularfire/ionic/cordova app and most specially with facebook auth, I have push the code of my service . 我在angularfire / ionic / cordova应用程序中有一个小问题,尤其是在使用facebook auth时,我已经推送了我的服务代码。 (I call my service function Auth.login in my Auth controller but it's this part of code who don't run) This code run perfectly whith ionic --serve. (我在Auth控制器中称呼我的服务函数Auth.login,但是这部分代码没有运行)。 But impossible to access to faceboook login on an emulator or my device(iphone). 但是无法在模拟器或我的设备(iphone)上访问faceboook登录。 When i click on " LOG IN WITH FB " i have nothing. 当我单击“使用FB登录”时,我什么也没有。 I don't understand how i can resolve this probleme. 我不明白如何解决这个问题。 Can you help me ? 你能帮助我吗 ?

app.factory("Auth", function($ionicModal, Findcity, $firebaseAuth,$localStorage, FirebaseUser, geoLocation ){

var provider = new firebase.auth.FacebookAuthProvider();
provider.addScope('user_birthday');
provider.addScope('user_location');
provider.addScope('email');
provider.addScope('user_photos');
provider.addScope('public_profile');
provider.addScope('user_about_me');


var Auth = {

login: function() {
  return $firebaseAuth().$signInWithPopup(provider)
    .then(function(result) {
      $localStorage.fbAccessToken = result.credential.accessToken;
      var facebookUser = firebaseAuth$().$getAuth().providerData[0];
      return FirebaseUser.get(facebookUser.uid)
      .then(function(user){
        console.log(facebookUser);
        if(user.$value == null) {
          console.log(user);
        FirebaseUser.save(facebookUser);
        }else {
         var lat = geoLocation.getGeolocation().lat;
         var lng = geoLocation.getGeolocation().lng;
         Findcity.city(lat, lng).then(function(city){
          var city_user = city;
          return firebase.database().ref('/users/' + facebookUser.uid).child('location').update({lat: lat, long: lng, city: city_user})
        })
      }
    })
  });
},
  return Auth;
});

Firebase 3.x signInWithPopup/Redirect is not currently supported in a Cordova environment. Cordova环境中当前不支持Firebase 3.x signInWithPopup / Redirect。 Until this is supported (work in progress), you can use other plugins to get the OAuth response for Facebook, Google and then use signInWithCredential instead. 在此方法得到支持之前(正在进行中),您可以使用其他插件来获取针对Facebook,Google的OAuth响应,然后使用signInWithCredential代替。 You can use something like https://www.npmjs.com/package/cordova-plugin-facebook to get the Facebook access token and then sign in via auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken)); 您可以使用https://www.npmjs.com/package/cordova-plugin-facebook之类的方法获取Facebook访问令牌,然后通过auth.signInWithCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken))登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase Facebook从iOS模拟器中的Ionic(Cordova)应用程序登录 - Firebase Facebook Login from Ionic (Cordova) app in iOS Emulator 使用离子电容器(capacitor-firebase-auth)更新 Facebook SDK - Update Facebook SDK with Ionic Capacitor (capacitor-firebase-auth) Cordova / Ionic Facebook getLoginStatus无法正常工作 - Cordova/Ionic Facebook getLoginStatus not working Firebase - 无法登录facebook auth - Firebase - Unable to login to facebook auth 带有Firebase消息传递和Firebase动态链接的Cordova Ionic项目 - Cordova Ionic project with Firebase Messaging and Firebase Dynamic Links 谷歌和Facebook Firebase Auth使用swift 3 - Google and Facebook Firebase Auth using swift 3 Firebase身份验证。谷歌+ Facebook =崩溃 - Firebase auth. Google + Facebook = Crash ionic - Firebase 身份验证:此域未授权用于 Firebase 项目的 OAuth 操作 - ionic - Firebase auth: This domain is not authorized for OAuth oprations for your Firebase project Facebook Auth和Firebase - 如何在同一Facebook应用程序下添加4个应用程序? - Facebook Auth and Firebase - How to add 4 apps under same Facebook app? 在Cordova / Ionic,如何在本机应用程序中打开Facebook个人资料链接? - In Cordova/Ionic, How to open a Facebook profile link in the native app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM