'How to use Flutter MethodChannel from FirebaseMessaging.onBackgroundMessage?
I'm using firebase_messaging onBackgroundMessage handler for listening push messages and it works as expected. Now I want to call platform method from this handler, but I'm unable to do this. MethodChannel can only be registered to Android Activity, but there is no Activity at this point. I was able solve my problem by creating custom Flutter plugin and implementing MethodChannel there, but this has some problems:
- Have to manage separate plugin code - unnecessary boilerplate and effort
- Hard to communicate between host application code and plugin code (e.g. wanting to use some method that is implemented on platform side in host application).
So the question is: is it possible to achieve same thing without plugin (e.g. create MethodChannel and register it globally). If it is possible for plugins, it should be possible for main application as well. Currently I only need to cover Android, if this makes things easier.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
