Skip to content

[firebase_messaging] background messaging documentation prob #199

Closed
@mobileink

Description

@mobileink

Describe the bug
It took me about three hours to figure out why my background message handler wasn't working. The documentation says "Define a top level Dart method to handle background messages." This is confusing, since there are no top level "methods", only top-level functions. Naturally I defined a handler in my class (it works for onMessage, ought to work for onBackgroundMessage, right?) and had to dig through the flutter source to figure out the problem.

To Reproduce
Steps to reproduce the behavior:

  1. Define your onBackgroundMessage callback the same way you define your onMessage handler, as a method in the class that calls _firebaseMessaging.configure
  2. Result:
    The following NoSuchMethodError was thrown building Builder:
    I/flutter (25669): The method 'toRawHandle' was called on null.
    I/flutter (25669): Receiver: null
    I/flutter (25669): Tried calling: toRawHandle()

Expected behavior

The documentation should be amended to indicate that the handler must be either a top level function, or a static method.

Thanks for the plugin!

Metadata

Metadata

Assignees

No one assigned

    Labels

    impact: crowdAffects many people, though not necessarily a specific customer with an assigned label. (P2)type: documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions