Closed
Description
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:
- Define your onBackgroundMessage callback the same way you define your onMessage handler, as a method in the class that calls _firebaseMessaging.configure
- 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!