2016-09-28 78 views
0

我使用PhoneGap爲Android和iOS開發跨平臺應用程序。訪問auth()並且驗證用戶可以在兩個平臺上正常工作,我可以在Firebase控制檯中驗證這些平臺。iOS 10,Firebase和PhoneGap - 獲取SSL錯誤

但是,訪問數據庫僅適用於Android。當我運行在iOS中相同的代碼,它給了我:

"Failed to load resource: An SSL error has occurred and a secure connection to the server cannot be made." 

我CSP包括firebaseio.com及其子域,一樣的​​3210。我還可以驗證Xcode中的ATS是否已啓用,並且在模擬器中運行PhoneGap應用程序時它會正確生成。

通過代碼舉例:

var adminRef = firebase.database().ref('/admin/'); 
    console.log('here'); 
    console.log(adminRef); 
    adminRef.on('value', function(snapshot) { 
     //do stuff with the result... 
} 

拋出的SSL錯誤。即使在配置中禁用APP傳輸安全性(因此也不允許連接通過)。

我錯過了什麼嗎?一切都是最新的。

回答

1

好吧,我想通了。在ios 10中訪問Firebase數據庫需要禁用前向保密。

在剛剛plist中,這意味着:

<key>firebaseio.com</key> 
    <dict> 
     <key>NSIncludesSubdomains</key> 
     <true/> 
     <key>NSExceptionRequiresForwardSecrecy</key> 
     <false/> 
    </dict> 

或者在科爾多瓦/ PhoneGap的,你可以在config.xml中禁用它:

<access origin="https://*.firebaseio.com" subdomains="true" requires-forward-secrecy="false"/> 

就我而言,我然後開始得到一個關於不在我的CSP中的websocket調用的錯誤。它是,但它不工作。在我的config.xml中,我還必須添加:

<access origin="wss://*.firebaseio.com" subdomains="true"/> 

現在在config.xml文件和構建工作中一切正常。 希望這可以節省別人的頭痛。