0

I am working on a Pebble watch app that uses Firebase.js. I managed to run Firebase.js on Android (by including it in pebble-js-app.js similar to https://github.com/tyhoff/clock) but no luck on IOS. I got this error when I simply include Firebase.js in my pebble-js-app.js:

TypeError: undefined is not a function (evaluating 'window.addEventListener("load",c,!1)')

user agent on IOS (not working): Ejecta/1.4 (iPhone6,1; OS 8.4.1)

user agent on Android(working): userAgent is Mozilla/5.0 (Linux; Android 5.0.1; SGH-I337M Build/LRX22C; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.121 Mobile Safari/537.36

It seems Firebase is calling something on browser that is not supported. Is there a workaround for this?

  • Did you look at this solution: http://stackoverflow.com/questions/29833443/accessing-firebase-using-cloud-pebble-pebble-js ? – sarfata Aug 28 '15 at 03:53

1 Answers1

1

I don't know anything about the Pebble environment and don't have one to test on, but it sounds like it's not a fully-functional browser and its window object is missing the addEventListener method? That makes me suspect you may not have much luck getting Firebase to work, unfortunately. :-/

You could try adding this to the beginning of your app (before you call new Firebase):

Firebase.INTERNAL.forceWebSockets();

This will avoid the code path that tries to attach a 'load' event listener, but it'll only work if Pebble supports WebSockets.

Alternatively, you could try to "polyfill" window.addEventListener and write a dummy implementation that just calls the callback immediately or something. But I'd be surprised if that successfully makes Firebase work.

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