iOS issues running application and loggin in with Firebase

I’m trying to deploy my application to iOS but I keep getting stuck when building to iOS and running the app in Xcode.

I run ionic cap build ios, sync ios, open ios, that’s ok. Sometimes I get the DerivedData folder issues, that’s ok. When everything is sorted, and I run the app, that’s when I have issues.

If I run it on an emulator, most of the time, I just get a blank screen. The app itself doesn’t really load. It opens, but it doesn’t load.

If I run it on my 11 Pro Max, the app launches but just shows a black screen. If I close it and open it again, sometimes it loads, but then I can’t get past login. I can register a new account, I can get a forgotten password email, but when I enter my details and press login, nothing happens. At the minute, the app won’t even load. Just a black screen.

I always get this error:
:zap: WebView loaded

:zap: ------ STARTUP JS ERROR ------

:zap: TypeError: undefined is not an object (evaluating ‘navigator.serviceWorker.addEventListener’)
:zap: URL: capacitor://localhost/assets/index-Dks_jw_K.js
:zap: index-Dks_jw_K.js:510:814

:zap: See above for help with debugging blank-screen issues
:zap: [error] - {}

But can’t really grasp what it wants me to do.

I’ve added all the relevant Firebase configuration, and the GoogleService plist file.

See When trying to run the code in IOS using xcode its not working, but in andorid its working perfectly - #2 by julio-ionic

Service workers don’t work on the WKWebView when using custom schemes

https://bugs.webkit.org/show_bug.cgi?id=206741

Thanks for this. I’m still not really sure where to go from here… I’ve ran grep -r “serviceWorker” and received thousands of lines, lots of node modules listed within a lot of errors.

Any idea what steps I need to take?

Some quick Googling points to possibly Firebase. See javascript - TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.addEventListener') - Stack Overflow.

Are you using the Firebase JS SDK/package? If so, trying commenting out that code and see if it works.

If it does work, then you’ll need to switch to a Capacitor plugin for Firebase.