khmyznikov / ios-pwa-wrap

Makes possible of publishing PWA to Apple Store like TWA from Google.
The Unlicense
153 stars 13 forks source link

push-notification event sent app in foreground, even without user clicking on the notification #11

Open sabres207 opened 7 months ago

sabres207 commented 7 months ago

Hey, I changed my app built with pwabuilder by the code you provider in this project, and everything works great. I also add code for sending the token to the js code, so we can store each user's token, and it also works. Thanks for that great work around!

On thing that bothers me tho, is that the push-notification event gets triggered directly when the phone gets the push, before the user even clicked on the notification. After the user clicks on the notification, the event fires again. This only happens when app is in foreground.

I tried to understand why it happens and what exactly in the calls of sendPushToWebView causes it, but I lack the knowledge in swift to get what's going on there.

Would appreciate any thoughts.

khmyznikov commented 7 months ago

Hmm try to debug this file: https://github.com/khmyznikov/ios-pwa-wrap/blob/iap/pwa-shell/AppDelegate.swift There is 4 calls of this function.

khmyznikov commented 7 months ago

I think there is two very similar events from FCM, but one triggers every time and another only while you click on notification... But the wrapper sends the same event probably? Try to identify them and you can tweak the behaviour.