3

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?

jwngr
  • 4,284
  • 1
  • 24
  • 27
  • What content is it trying to load? http://msdn.microsoft.com/en-us/library/windows/apps/hh465373.aspx it's not possible to override the behavior with a switch. The app must change. – WiredPrairie Nov 07 '13 at 12:12
  • This should work, but it looks like it's not properly detecting its in Windows 8 and defaulting to WebSockets. As a temporary workaround (until we fix firebase.js), you can try adding this at the start of your app: Firebase.INTERNAL.forceWebSockets() – Michael Lehenbauer Nov 07 '13 at 16:05
  • @MichaelLehenbauer adding that line of code worked for me and I can now write and read from my Firebase. Thanks a lot! I do still get the following error message though when I call the set() method: "WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally." It doesn't seem to affect functionality but it would be nice to clean up my console and not have the error. Any idea what's going on there? – jwngr Nov 08 '13 at 05:30
  • 1
    @IrishFatty11 Hrm. Not sure. I've opened a bug for us to investigate Firebase / Win8 compatibility again to get everything working smoothly. I'll make sure you don't need any extra code or get weird console errors. Until then you'll have to put up with it. Sorry! – Michael Lehenbauer Nov 10 '13 at 01:06
  • @MichaelLehenbauer no problem - and thank you! I appreciate you looking into it. I'll keep an eye on any fixes you make. – jwngr Nov 12 '13 at 04:07
  • @MichaelLehenbauer I'm wondering if there is any more news with respect to this issue? – garyrob Jan 26 '14 at 16:08
  • @garyrob This should work just fine. I tested it a month or two ago, and it worked for me. If you run into any issues, please let me know. michael@firebase.com – Michael Lehenbauer Jan 26 '14 at 21:31

2 Answers2

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.

Michael Lehenbauer
  • 16,229
  • 1
  • 57
  • 59
-1

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...

Dennis Smolek
  • 8,480
  • 7
  • 30
  • 39
  • This is a regression. What version of Windows are you using? It definitely looks like the detection logic is broken for you as we should be using web sockets here. Are you by chance using some new Windows 10 stuff? – jwngr May 06 '15 at 04:20
  • I dont really know what caused it before, I switched to firebase-debug to test it, I couldnt get it to log anything so I switched back and left out my Force call and now it's working as expected.. Not sure if some other error on my part triggered the initial problem or what exactly.. – Dennis Smolek May 07 '15 at 10:29
  • Just an update, I removed the FORCE flag as my dev tests never reproduced the issue, but then the app started having a sudden crash cycle of death. I reverted the commit and isolated the issue to the FORCE call being gone. I'm not sure why at this moment but I suggest keeping the force.. – Dennis Smolek May 12 '15 at 04:48