Call onMessage method when the app is in background in flutter

后端 未结 4 1509
时光取名叫无心
时光取名叫无心 2020-12-10 20:17

I\'m new in flutter and dart. I\'m trying to connect my app with FCM. When app is in foreground I create flutterLocalNotificationsPlugin and everything works fine, but I don

4条回答
  •  攒了一身酷
    2020-12-10 20:48

    The Dart VM does not run while the app is in background. That means you have to handle notifications and data messages in native code (Java/Kotlin/ObjectiveC/Swift).

    To do this on Android, refer to the official documentation.

    You will probably have to remove the firebase_messaging plugin and do all the message handling manually. To send the notification content to your flutter app (while it is in foreground), use platform channels.

    It really helps to look at the source code of the firebase_messaging plugin to see what happens on the native side.

提交回复
热议问题