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

bug: android notification not triggers onMessageReceived if the app is killed #419

Closed
4 of 13 tasks
NLueg opened this issue Aug 8, 2023 · 2 comments
Closed
4 of 13 tasks
Labels

Comments

@NLueg
Copy link
Contributor

NLueg commented Aug 8, 2023

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Messaging
  • Performance
  • Remote Config

Did you test the latest version?

  • I use the latest version

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

When I trigger a notification for my Android device (it doesn't matter if silent or not) the onMessageReceived method of the FirebaseMessagingPlugin is called but not forwarded to my app.

I investigated the issue a bit more and the problem is that getFirebaseMessagingPluginInstance returns null as you can see in the screenshot. And this is because the staticBridge is null because the plugin (and the whole activity) is not loaded.

Expected behavior

Notifications should trigger the Capacitor listener for onMessageReceived even if the application is killed.

Reproduction

https://github.com/NLueg/android-killed-notification-issue

Steps to reproduce

It's actually not easy to provide an example for such issues as this would require publishing the firebase configuration. Do you have a solution for this? If you never heard of such a problem I will try to add it to the example

  1. Install the @capacitor-firebase/messaging plugin
  2. Send a notification to the opened app (onMessageReceived is called)
  3. Close the app
  4. Send the same notification again (onMessageReceived is not called)publishing

Other information

Bildschirm­foto 2023-08-08 um 18 17 44

Capacitor doctor

Latest Dependencies:

@capacitor/cli: 5.2.2
@capacitor/core: 5.2.2
@capacitor/android: 5.2.2
@capacitor/ios: 5.2.2

Installed Dependencies:

@capacitor/cli: 5.2.2
@capacitor/core: 5.2.2
@capacitor/ios: 5.2.2
@capacitor/android: 5.2.2

Before submitting

  • I understand that incomplete issues (e.g. without reproduction) are closed.
@NLueg NLueg added bug/fix Something isn't working needs: triage labels Aug 8, 2023
@robingenz
Copy link
Member

Hi @NLueg, thank you for your request!

Notifications should trigger the Capacitor listener for onMessageReceived even if the application is killed.

It triggers the listener, but only on the next app launch, not immediately. If the app is killed, then no method can be called in the WebView.
If you want to execute code while the app is killed, then you have to write native code that does not run in the WebView.

@NLueg
Copy link
Contributor Author

NLueg commented Aug 10, 2023

Thank you for the fast response! Okay, actually I already thought that. But I hoped that you already have a solution for this 😆
When I am able to solve this, I will post the solution here.

@NLueg NLueg closed this as completed Aug 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants