2017-04-10 38 views
1

我不知道它何時發生,因爲在開發過程中,我在瀏覽器中啓動了會話,所以我不必再次通過Google或Facebook等提供商登錄。當一位新用戶試圖在我的網絡應用程序中登錄時,她告訴我發生了錯誤。因此,我清理了我的瀏覽器數據,並在瀏覽器嘗試打開Goog​​le或Facebook登錄彈出窗口時開始輸入消息A network error (such as timeout, interrupted connection or unreachable host) has occurred.。它不會在Safari或我的Android Chrome中發生。Firebase身份驗證不適用於Chrome瀏覽器

下面是一個代碼片段作爲參考。

<!-- 
@license 
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. 
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 
Code distributed by Google as part of the polymer project is also 
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 
--> 

<link rel="import" href="../bower_components/polymer/polymer.html"> 
<link rel="import" href="../bower_components/paper-button/paper-button.html"> 
<link rel="import" href="../bower_components/polymerfire/polymerfire.html"> 
<link rel="import" href="shared-styles.html"> 

<dom-module id="my-view1"> 
    <template> 
    <style include="shared-styles"> 
     :host { 
     display: block; 

     padding: 10px; 
     } 
    </style> 

    <div class="card"> 
     <div class="circle">1</div> 
     <paper-button on-tap="login">Login</paper-button > 
     <h1>View One</h1> 
     <p>Ut labores minimum atomorum pro. Laudem tibique ut has.</p> 
     <p>Lorem ipsum dolor sit amet, per in nusquam nominavi periculis, sit elit oportere ea.Lorem ipsum dolor sit amet, per in n# 
    </div> 
    </template> 

    <script> 
    Polymer({ 
     is: 'my-view1', 

     login: function(){//{{{ 
     firebase.initializeApp({ 
      apiKey: apiKey, 
      authDomain: authDomain, 
      databaseURL: databaseURL 
     }); 

     var provider = new firebase.auth.FacebookAuthProvider(); 
     firebase.auth().signInWithPopup(provider).then(function(result){ 
      console.log(result); 
     }).catch(function(error){ 
      console.error(error); 
     }); 
     },//}}} 
    }); 
    </script> 
</dom-module> 

回答

0

我想你應該在有人點擊登錄前初始化應用程序。

firebase.initializeApp({ 
    apiKey: apiKey, 
    authDomain: authDomain, 
    databaseURL: databaseURL 
}); 

每當有人登陸頁面可能是最好的地方做到這一點。

+0

不是。我已經測試過了。 –

相關問題