[英]IOS notification don't show image
对于 Flutter iOS,我连接了 firebasemessag。 APNS也已连接,它也在工作。 但它没有在 IOS 上显示图片。 为此,我添加了通知服务扩展作为目标。 如果我 select Objective-C 代码,它会在构建时出错。 如果我选择 Swift 代码,我无法弄清楚如何将 Firebemessaging 的相关部分添加到其中?
我建议您使用HTTP v1
api
https://firebase.google.com/docs/cloud-messaging/migrate-v1
按照上面的链接迁移到HTTP v1
这是有效载荷,它将在通知中显示图像
https://firebase.google.com/docs/cloud-messaging/ios/send-image
{
"message":{
"token":"your token will be here",
"notification":{
"title":"Sparky says hello!",
},
"android":{
"notification":{
"image":"https://foo.bar/pizza-monster.png"
}
},
"apns":{
"payload":{
"aps":{
"content-available" : 1
"mutable-content":1
}
},
"fcm_options": {
"image":"https://foo.bar/pizza-monster.png"
}
},
"webpush":{
"headers":{
"image":"https://foo.bar/pizza-monster.png"
}
}
}
}
并使用flutter_local_notifications
插件
const AndroidNotificationChannel channel = AndroidNotificationChannel(
'channel_id', // id
'High Importance Notifications', // title
description:
'This channel is used for important notifications.', // description
importance: Importance.high,
);
var iosNotificationDetails =
IOSNotificationDetails(attachments: <IOSNotificationAttachment>[
IOSNotificationAttachment(yourPicturePath),
]);
var androidNotificationDetails =
AndroidNotificationDetails(channel.id, channel.name,
channelDescription: channel.description,
enableLights: true,
icon: "ic_f",
playSound: true,
priority: Priority.high,
importance: Importance.max,
styleInformation: BigPictureStyleInformation(
FilePathAndroidBitmap(yourPicturePath),
));
var notificationDetail = NotificationDetails(
iOS: iosNotificationDetails, android: androidNotificationDetails);
Random random = Random();
await flutterLocalNotificationsPlugin.show(
random.nextInt(10000),
"title",
"body",
notificationDetail);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.