问题
I'm hoping to use Firebase in my Windows 8 app made using WinJS. Here is how I am trying to write to the root of my Firebase:
var dataRef = new Firebase("https://<firbaseName>.firebaseio.com");
dataRef.set("I am now writing data into Firebase!");
However, this gives me the following error in the JavaScript console:
Can’t load <https://<firebaseName>.firebaseio.com/.lp?start=t&ser=66595697&cb=2&v=5>. An app can’t load remote web content in the local context.
I've tried to add https://[firebaseName].firebaseio.com/* to my Content URIs in my app manifest but that doesn't seem to be the solution. Does anyone know if it's possible to get Firebase working inside of a Windows 8 app?
回答1:
You should be able to use firebase.js natively in a Windows 8 (WinJS) app. Just download a copy, and embed it with your app. If you run into any issues, please email support@firebase.com.
回答2:
I wanted to add that is not possible to use the regular firebase.js file alone. (5/5/15 and firebase.js 2.2.4)
The issue is firebase by default tries to do long polling and calls a script from firebase which violates CSP.
Firebase.js has a function called isWindowsStoreApp() but in my tests it doesn't work.
What @Michael Lehenbauer said in an earlier comment triggers it to only use websockets which is local and CSP safe.. Just call
Firebase.INTERNAL.forceWebSockets();
early and it works...
来源:https://stackoverflow.com/questions/19828632/is-it-possible-to-use-firebase-with-a-windows-8-app