ServiceWorker registration fails in Facebook/Instagram in-app browser on iOS
- Dominant language
- TypeScript
- Stars
- 7.8k
- Forks
- 2.2k
- Avg merge
- 22h 28m
- Merged PRs (30d)
- 6
Description
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:
```typescript
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:
```typescript
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
Contributor guide
Research direction
Start at the messaging-service initialization call shown in the issue and reproduce it in Facebook/Instagram's iOS in-app browser. Trace how navigator.serviceWorker is accessed; done means initialization no longer throws when the API is unavailable, with push behavior verified where supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, firebase, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100