[firebase_messaging] Handle background messages in a kotlin project #5599
Replies: 4 comments
-
Here https://github.com/hw-dwalter/flutter-firebase-messaging-background-example you can find my sample project with working background messages in kotlin. everything is fine except of this behaviour https://youtu.be/frhnHX8Z-UQ |
Beta Was this translation helpful? Give feedback.
-
Any idea how to integrate MethodChannels in this scenario? |
Beta Was this translation helpful? Give feedback.
-
+1 to this, I had no idea that the android portion of my Flutter project was in Kotlin rather than Java until I got to the 'create MainActivity.java' instruction and got stuck. So the instructions are currently unclear. Have followed the guides above (thanks so much for writing!) and can now send messages but not background messages. |
Beta Was this translation helpful? Give feedback.
-
Is this right?
The guide says : 6 Add a new |
Beta Was this translation helpful? Give feedback.
-
It seems there's no official documentation on handling background messages in a kotlin based project.
Please write documentation for it, there's a lot of confusion around this.
I tried to search similar issues and stumbled upon:
#111
As suggested in that issue, I added the following Application.kt:
I removed configureFlutterEngine from MainActivity.kt (well, until this is solved it's just commented out):
I modified android:name in AndroidManifest.xml:
I added
com.google.firebase:firebase-messaging
toapp/build.gradle
:When trying to build, I got the following error:
I then stumbled upon:
https://stackoverflow.com/a/60531819/5882529
After following it I was finally able to build, but I'm not able to intercept any background message.
I'm testing on Android Emulator: Pixel 3a, Android Q.
That's what I get when I run
flutter doctor -v:
I have IntelliJ IDEA Community Edition installed separately from Android Studio but I'm using Android Studio which does have the Flutter and Dart plugins installed, so that warning can be ignored.
Beta Was this translation helpful? Give feedback.
All reactions