Firebase, touchpad etc.

Working on packaging my enyo2 app for the touchpad & webos. It incorporates firebase.js and when I'm opening my app it is opening a browser page and navigating to a firebase page. Any way I can keep that from happening? It's obviously coming from the code in the firebase header you have to incorporate to make firebase work in your app.

Comments

  • Apps in webOS can't pull in remote scripts directly using script tags. You'll have to write a loader that requests the script using a XHR then evals it, or just have a local copy of their JS code in your app.
  • or just have a local copy of their JS code in your app
    This is not recommended practice, per Firebase. They update the client library fairly frequently, and you can get really weird behavior if your firebase.js gets out of sync with their servers.
  • Ok, yeah,

    local copy isn't recommended. Maybe when it's no longer beta.

    I'll xhr it. The funny thing is it works. It just keeps popping out to webbrowser pages occasionally. Annoying more than breaking the app.
  • @unwiredben The other funny thing about packaging my app is I have the exact opposite problem on webOS that I had on Android about pulling crossdomain. With webOS I must put the username/password in the ajax object whereas in Android I must put them in the header using Basic Authentication.
  • FYI,

    Works fine to do this in WebOS. In Android, I did have problems with freezing occasionally if firebase wouldn't load for whatever reason when I put it in the script tag in the head. To load it on demand, I did this:
    var p = document.createElement("script");
    p.innerText = inSender.xhr.response;
    document.body.appendChild(p);
    try {
    eval(p.innerText);
    } catch (e) {
    console.log(e);
    }
  • Scratch that it works in webOS. I get this error after I eval it:
    com.palm.app.browser WARNING: Executing pending window params, but no params list found., file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:6242
    com.palm.app.browser enyo.BrowserApp.create():  {"target":"https://s-ord-nss-2.firebaseio.com/.lp?dframe=t&id=55303&pw=dANziVrinj&ns=designtech"}, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BrowserApp.rendered(): , file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.create():  cache true, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.callBrowserAdapter():  queued! setMinFontSize, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.callBrowserAdapter():  queued! setEnableJavaScript, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.callBrowserAdapter():  queued! setBlockPopups, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.callBrowserAdapter():  queued! setAcceptCookies, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.callBrowserAdapter():  queued! setHeaderHeight, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser enyo.BasicWebView.callBrowserAdapter():  queued! ignoreMetaTags, file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    com.palm.app.browser Browser.urlChanged():  , file:///usr/palm/frameworks/enyo/0.10/framework/build/enyo-build.js:72
    So it still pops up a window when I try to use firebase.
  • Also, FYI, after evaling I had to give a 2 sec timeout in order to let Firebase's script run properly otherwise I froze regularly.
  • That's kinda insane. JavaScript is synchronous, but maybe they're setting up a bunch of setTimeouts that they use to do more processing before they're ready. Is there any kind of event that the Firebase code sends to let you know that it's ready to go?
  • Good idea. I'll check. Does webOS support websockets?

  • I was checking on firebase google group. It looks like this also happens in certain scenarios with phonegap and ios as well. So it could be a phonegap setting to pop out links?
  • webOS 3.0 supported an older version of websockets. 2.x and earlier didn't, IIRC.
  • Is it possible they're using an iframe to communicate with their server for any reason? That would explain why it's opening a browser window on webOS and why iOS would see the same issue if the URLs aren't set properly with PhoneGap.
  • Yeah, I think that's possible. how would you work around it?
  • You can't. webOS apps can't create iframes that load a non-file context. That's what the WebView control is for, but that doesn't allow for useful communication.
Sign In or Register to comment.