[英]How to set image in notification in react-native?
在Android,Native应用程序中,您可以轻松地在通知中设置图像。
我需要在我的应用程序中创建此功能。 我正在使用https://github.com/evollu/react-native-fcm我认为,我必须为覆盖通知构建器创建新活动。 但我很困惑我可以在哪里使用Javascript覆盖java类。 本教程帮助我了解如何在本机应用程序中实现图像通知。
谢谢。
对于图像,您可以使用react-native-fcm
包在custom_notification
使用picture
。 它应该看起来像:
const payload = {
data: {
snapshot: JSON.stringify(original),
custom_notification: JSON.stringify(
{
id: 'topics/my-notif
title: `title`,
body: '',
sound: 'default',
priority: 'high',
icon: 'ic_launcher',
show_in_foreground: true,
vibrate: 300,
action: 'android.intent.action.MAIN',
picture: 'https://asfsgsgafasfaf',
}
)
}
//,notification:{title: `Car(${original.name}) registrated`,body: 'Waiting administration approve. ' + original.description}
};
但如果您使用Firebase存储,这是一个小问题。 包覆盖firebase链接。 从%2F
到/
。 这是一个错误,我在这里打开了问题: https://github.com/evollu/react-native-fcm/issues/931
: https://github.com/evollu/react-native-fcm/issues/931
也许应该合并。 因此,当您从firebase存储中放置图像时,它无法获取它并显示空白图像...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.