Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceWorker registration fails in Facebook/Instagram in-app browser on iOS #3630

Open
veneliniliev opened this issue Feb 27, 2025 · 3 comments

Comments

@veneliniliev
Copy link

When using the Firebase Messaging service with Angular 19.1.4 in the Facebook/Instagram in-app browser on iOS devices, the following error occurs:

TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.addEventListener')

Environment

  • Platform: iOS
  • Browser: Facebook/Instagram in-app browser
  • Framework: Angular 19.1.4
  • Dependencies:
    • @angular/core: 19.1.4
    • @angular/common: 19.1.4
    • @angular/platform-browser: 19.1.4
  • Service: Firebase Cloud Messaging

Technical Details

The error occurs during the messaging service initialization when attempting to add an event listener to the ServiceWorker. The specific line causing the issue is:

navigator.serviceWorker.addEventListener('message', e => messageEventListener(messaging as MessagingService, e));

Root Cause

The Facebook/Instagram in-app browser on iOS does not support or properly expose the ServiceWorker API, causing navigator.serviceWorker to be undefined. This issue persists even with the latest Angular 19 framework.

Impact

  • Firebase Cloud Messaging service initialization fails
  • Push notifications cannot be registered or received
  • Affects only users accessing the Angular 19 application through Facebook/Instagram in-app browser on iOS devices
@google-oss-bot
Copy link

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@aaltepet
Copy link

aaltepet commented Mar 4, 2025

+1 I have the same problem with an ionic app that uses @angular/fire/messaging. When the app is built for ios, starting the native ios app throws the same error.

@veneliniliev
Copy link
Author

veneliniliev commented Mar 5, 2025

@aaltepet I use this solution: firebase/firebase-js-sdk#8817 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants