I am using firebase_messaging
in my flutter application, and I want to be able to debug what happens when the onLaunch
callback fires.
The problem is that it fires when a notification is received and the app is terminated.
There has to be a way to debug it right?
So following OP discussion you could debug the
onLaunch
withprint()
ordebugPring()
function.You can use the adb command line to get logcat output on terminal like this
if you have more than one device you could use the
-s
parameter in order to choose your device.-e
is for filter only log message that has a flutter word inside-v
color is to have a formatted color outputAs data message are not supported by Android plugin you could send a
notification
message in order to have theonLaunch
called providing also thisdata
field:You can send a message like that
The problem is that you get different
Map
message JSON:onMessage
you getInstead in
onLaunch
andonResume
you getI've get my
printDebug
function withadb
:So in
onMessage
you can get the foo field like thatand in
onLaunch
you can get it like that:UDATE: iOS device
The above debugging sessione is for an Android device.
On a iOS device in order to get the console output of the device you could use Apple App Configurator 2 or the
Console
application (fromUtilities
folder inside yourApplications
folder):on
onMessage
you will receive:and on
onResume
andonLaunch
:They are the same, so I suggest to check the platform before getting your custom data in
onMessage
.For that you could use
dart.io
libraryPlatform
class: