颤音:FCM背景通知大图标

发布于 2025-02-04 21:06:02 字数 451 浏览 4 评论 0原文

我正在使用firebase_messaging和flutter_local_notifications进行通知,并且在局部(前景)通知的情况下,我能够显示一个大图标,但是当应用程序为背景时,我似乎并没有找到一种显示同一大图标的方法。

“背景”

I'm using firebase_messaging and flutter_local_notifications for notifications, and I was able to show a large icon in case of local(foreground) notifications, but I didn't seem to find a way to show the same large icon when the app is background.
foreground

background

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

挽心 2025-02-11 21:06:02

处理背景Noti并使用本地通知显示Noti。

firebasemessaging.onbackgroundMessage(_FireBasemessagingBackgroundHandler);

handle background noti and show noti using local notification.

FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

雾里花 2025-02-11 21:06:02

使用bladicon的更好方法是在发送通知时使用Notification Poreload中的Image属性:

const payload = {
  notification: {
    title: 'title',
    body: 'description',
    image: 'large_icon_url',
    sound : "default"
  },
};

A better way to use largeIcon is using the image property in notification payload when you are sending the notification:

const payload = {
  notification: {
    title: 'title',
    body: 'description',
    image: 'large_icon_url',
    sound : "default"
  },
};
孤檠 2025-02-11 21:06:02

1-在背景中使用Flutter_local_notifications显示图像

2-在有效载荷中删除“通知”,然后将数据添加到
“数据:{
标题:“标题”,
身体:“描述”,
图像:“图像”,
}”

1- use flutter_local_notifications in backgroundMessageHandler to display the image

2- remove the "notification" in the payload and add your data in
"data:{
title: 'title',
body: 'description',
image: 'image',
}"

み格子的夏天 2025-02-11 21:06:02

此代码可帮助您接收通知并在应用程序中使用:

void initMessaging() {
var androiInit = AndroidInitializationSettings(‘@mipmap/ic_launcher’);//for logo
  var iosInit = IOSInitializationSettings();
  var initSetting=InitializationSettings(android: androiInit,iOS:
   iosInit);
  fltNotification = FlutterLocalNotificationsPlugin();
  fltNotification.initialize(initSetting);
  var androidDetails =
   AndroidNotificationDetails(‘1’, ‘channelName’, ‘channel 
    Description’);
  var iosDetails = IOSNotificationDetails();
  var generalNotificationDetails =
   NotificationDetails(android: androidDetails, iOS: iosDetails);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {     RemoteNotification notification=message.notification;
   AndroidNotification android=message.notification?.android;
   if(notification!=null && android!=null){
     fltNotification.show(
       notification.hashCode, notification.title, notification.
       body, generalNotificationDetails);
}
});
}

如果您有任何困难,请查看本文: flutter推动通知介质
谢谢。

This code help you to receive a Notification and to use in your app :

void initMessaging() {
var androiInit = AndroidInitializationSettings(‘@mipmap/ic_launcher’);//for logo
  var iosInit = IOSInitializationSettings();
  var initSetting=InitializationSettings(android: androiInit,iOS:
   iosInit);
  fltNotification = FlutterLocalNotificationsPlugin();
  fltNotification.initialize(initSetting);
  var androidDetails =
   AndroidNotificationDetails(‘1’, ‘channelName’, ‘channel 
    Description’);
  var iosDetails = IOSNotificationDetails();
  var generalNotificationDetails =
   NotificationDetails(android: androidDetails, iOS: iosDetails);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {     RemoteNotification notification=message.notification;
   AndroidNotification android=message.notification?.android;
   if(notification!=null && android!=null){
     fltNotification.show(
       notification.hashCode, notification.title, notification.
       body, generalNotificationDetails);
}
});
}

If you have any difficulty, please check this article : Flutter Push Notification Medium.
Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文