firebase / firebase/firebase-js-sdk
[Bug]: Service worker event listeners don't work in iOS if app is opened from home screen.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### Operating System
iOS 16.4.1 (a)
### Browser Version
Safari
### Firebase SDK Version
9.22.0
### Firebase SDK Product:
Messaging
### Describe your project's tooling
NodeJs Express
### Describe the problem
In the demo app, I listen on messages posted from service worker.
As you can see in the video on desktop Safari it works as intended but it doesn't on iOS (16.4.1 (a) - iPhone 8)
With further investigation I found out event listeners in service workers are not always called,
if I open the app from home screen clicks on notification don't do anything, but if the app is opened by click on notification then it works as intended, meaning clicks on next notification trigger event listeners in service worker.
https://github.com/firebase/firebase-js-sdk/assets/16229997/0ddcf4c4-c213-493f-80cb-ca72222e6af6
### Steps and code to reproduce issue
- Save the app to Home screen
- Open the app and allow notoficitations, wait for token to be generated
- Close the app
- Reopen the app
- Click "Notify all"
- Click on received notification
Here you can see the reproduction demo https://github.com/stefan-krajnik/fcm-web-push-example
Provide correct firebase config here - https://github.com/stefan-krajnik/fcm-web-push-example/blob/master/index.html#L80
Generate Firebase Admin SDK private key and provide correct path to it - https://github.com/stefan-krajnik/fcm-web-push-example/blob/master/server.js#L5
I deployed the reproduction app to https://fcm-webpush-test.onrender.com
Contributor guide
Research direction
Start with the reproduction steps and the linked fcm-web-push-example, especially index.html line 80 and server.js line 5; provide the required Firebase config and Admin SDK key. Compare behavior when launching from the Home screen versus a notification, and verify that service-worker event listeners respond consistently on iOS 16.4.1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, firebase, ios, node.js, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100