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

[firebase-messaging] onNotificationTap not called when app was closed #77

Closed
jessorlisa opened this issue Apr 4, 2022 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@jessorlisa
Copy link

Issue with message handlers in @nativescript/firebase-messaging

Angular flavor

Handlers are added in a service: FirebaseService (src/app/core/services/firebase/firebase.service.ts)

3 test scenarios:

  • ✅ FCM message received while in foreground: onMessage (Android/iOS)
  • ✅ notification tapped while in background: onNotificationTap (Android/iOS)
  • ❗ notification tapped while closed: none (Android/iOS)

Expected result: onNotificationTap is called when app was closed and notification was tapped.

I set up a simple demo project to show the current issue:
https://github.com/jessorlisa/demo-issues-nativescript-ng/tree/issue/firebase-messaging

All relevant information can be found in the "Issue description" and "Reproduction" section.

Initially reported here: #42

@triniwiz triniwiz added the bug Something isn't working label Apr 25, 2022
@cdroege
Copy link

cdroege commented May 11, 2022

I had the same problem at first, but if I add the onNotificationTap handler early by defining it in the main.ts file, it works (on iOS and Android). So this might be caused, when the handler is defined late in the app startup process?

@jessorlisa
Copy link
Author

Thanks, @cdroege I tried this weeks ago, sadly this was only working on Android, not on iOS.
#42 (comment)

Anyway, I need this in a service, otherwise there is no option to e.g. navigate on notification tap.

My setup was working flawless with the deprecated firebase plugin (and still is) - but sadly not with the new one.

@triniwiz Do you by any chance have an ETA when you can take a look at this? I see you aknowledged it as a bug. Thanks.

@jessorlisa
Copy link
Author

jessorlisa commented May 19, 2022

@triniwiz Could we please reopen this? I am afraid the issue is still the same. 😞

Please check my demo project, I have updated the plugin to 2.0.0. Stil no onNotificationTap is triggered when the app was closed on notification tap.

Edit: I have to apologize, it is working if I remove the APP_INITIALIZER from the app providers. What do I have to do to make this work with an APP_INITIALIZER? (As it does with the legacy plugin).

@jessorlisa
Copy link
Author

@triniwiz I found a solution that seems to be working.
I "simply" added the handlers in a second APP_INITIALIZER token, as you can see here.

So consider the issue as closed.

(I will keep the demo open, maybe this may help somebody else.)

Thanks for the great work you are doing here! 🚀 Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants