4

當嘗試我的Android手機上進行測試期間登錄到我的web應用程序,我得到這個消息:使用與Facebook火力權威性

「firebase.js:75未捕獲的錯誤:該操作未在環境中支持此「location.protocol」必須是http或https ..「

我將我的firebase url添加到我的fb應用上的有效OAuth重定向URI - https://.firebaseio.com/我添加了我的應用ID和名稱到身份驗證部分的Firebase。我錯過了什麼嗎?感謝

我在這裏使用Chrome遠程調試:文件:///android_asset/www/index.html#/app/people

難道這是爲什麼它把一個大驚小怪的?

var provider = new firebase.auth.FacebookAuthProvider(); 

console.log(provider); 
    firebase.auth().signInWithPopup(provider).then(function(result) { 
// This gives you a Facebook Access Token. You can use it to access theFacebook API. 
    var token = result.credential.accessToken; 
// The signed-in user info. 
    var user = result.user; 
    console.log(user, token); 
    UserService.setUser(user, token); 
// ... 
}).catch(function(error) { 
    // Handle Errors here. 
    var errorCode = error.code; 
    var errorMessage = error.message; 
    // The email of the user's account used. 
    var email = error.email; 
    // The firebase.auth.AuthCredential type that was used. 
    var credential = error.credential; 
    console.log(errorCode); 

    }); 
+0

認證將無法正常工作用'file://'。您需要從適當的Web服務器加載HTML以使其正常工作。 –

+0

是的。我是這麼想的。即時通訊使用輕量級輕量級adb在我的手機上運行應用程序。也許,我可以以某種方式從節點上運行它。有什麼建議麼?謝謝。 –

+0

只是啓動本地服務器。有很多節點模塊,只需在npm上搜索即可。 – luschn

回答

1

以下操作:signInWithPopup,signInWithRedirect,linkWithPopup,linkWithRedirect和getRedirectResult只從一個HTTP/HTTPS環境支持。您可以使用文件環境中的其餘apis。

3

在關於Facebook的登入,適用於離子1,應在校長也對離子2.

添加科爾多瓦插件科爾多瓦 - 插件 - facebook4 在授權碼,我工作中發現一個變通已經添加了以下內容:

if ((window.cordova && device.platform == 'iOS') || (window.cordova && device.platform == 'Android')) { 
    facebookConnectPlugin.login(['public_profile'], function(result) { 
     provider = firebase.auth.FacebookAuthProvider.credential(result.authResponse.accessToken); 
     Auth.$signInWithCredential(provider).then(function(authData) { 
      // User successfully logged in 
     }).catch(function(error) { 
      // Login error 
     }); 
    }, function(error) { 
     // Login error 
    }); 
} else { 
    provider = new firebase.auth.FacebookAuthProvider(); 
    Auth.$signInWithPopup(provider).then(function(authData) { 
     // User successfully logged in 
    }).catch(function(error) { 
     // Login error 
    }); 
} 

基本上,這將確保在設備上,它使用Facebook登錄SDK,而在瀏覽器中運行時,它會使用火力地堡signInWithPopup時加載文件