如何在 flutter 中的 firebase 推送通知中显示图像

How to show image in firebase push notification in flutter

我想在 flutter 的推送通知中显示图像。我在来自服务器的消息对象中有图像 url,使用此 url 我想在 android 和 iOS 设备中透传图像。我怎样才能做到这一点。感谢您的帮助。

在此处查看有关图像的 firebase 文档: https://firebase.google.com/docs/cloud-messaging/ios/send-image

如果使用云存储,图像有 300KB 的限制和额外的报价限制。

对于通知,您可以使用 https://pub.dev/packages/flutter_local_notifications 这个程序包

查看 showBigPictureNotification() https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/example/lib/main.dart

这是 firebase_messaging 包中的内置功能。

您需要做的就是在通知负载中设置图像以及其他值,例如 body标题

参考文献:https://firebase.google.com/docs/cloud-messaging/android/send-imagehttps://developer.android.com/training/notify-user/expanded