Skip to content

🐛 [firebase_messaging] "No Firebase App..." in background message handler #3520

Closed
@rubenvereecken

Description

@rubenvereecken

Bug report

Describe the bug
My background message handler always throws the error

I/flutter (27134): Unable to handle incoming background message.
I/flutter (27134): [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

Closer inspection of the stacktrace revealed that it threw because it relies on code that relies on the FirebaseAuth.instance.

Steps to reproduce

Steps to reproduce the behavior:

  1. Start app
  2. Send app to background
  3. Send data only message
  4. Witness the background message handler crash

Expected behavior

I would expect to be able to use Firebase in the background message handler. This seems not to be the case and I'd like to figure out what the limitations are. Is this expected behavior? Can I get around it by initializing firebase inside the message handler? Globals don't seem to be shared - a separate thread or isolate then? If this is indeed expected (the docs don't really say as much) - what is the advised way to pass messages to other parts of the app, say so that data can be displayed when it opens again? Or is there no way to communicate back to "the main thread"?


Flutter dependencies

  firebase_core: ^0.5.0
  firebase_analytics: ^6.0.0
  firebase_messaging: ^7.0.0
  firebase_auth: ^0.18.0+1
  firebase_remote_config: ^0.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions