-1

I am building a site in react and I make use of capacitor to build mobile apps. I've managed to build successfully to the google play store and the apple app store once. Then I added firebase for mobile notifications and added on-site features, that turned out to break the iOS build of capacitor.

TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.addEventListener')
URL: capacitor://localhost/static/js/hash.chunk.js

Debug tips as well as solutions would be appreciated!

  • Hi Martijn! would you please update your question to contain the actual error information? It's easy for links to go stale, and hard for folks to understand the question in that case. – Robert P Sep 15 '21 at 16:09

1 Answers1

1

The new features appear to be attempting to use service workers. Your issue likely has to do with an http request that is not http://localhost. Service workers only appear to work with ssl connections (https) and http://localhost.

Per this article iOS uses capacitor://localhost and on android it uses http://localhost. So Android would work, iOS would not. You can see these links in Xcode as well.

I've added some references below. I think your solution is to figure out how to configure the newly added packages (firebase, etc) to not use service workers. If that is not possible, you may have to remove the features that use service workers for iOS.

Here is an issue as well. And this.

This article points out the issue. And this thread discusses changing capacitor://.

More references which may help:

Stack Overflow

You need HTTPS header in google docs

Firebase and Service Workers

Diesel
  • 5,099
  • 7
  • 43
  • 81