React native 加载图像并将其作为图标传递给本机代码
在我的应用程序中,我想加载一个图像,稍后将用作前台通知图标 我是这样做的:React native 加载图像并将其作为图标传递给本机代码,react-native,react-native-android,React Native,React Native Android,在我的应用程序中,我想加载一个图像,稍后将用作前台通知图标 我是这样做的: const imagePath = require('path-to-image'); 当我在imagePath上记录该值时,我得到了值3。它是什么意思-它像资源id吗 然后,我将该imagePath传递给本机Java层,并使用它创建通知: int resId = config.getNotificationIconPath(); // Here I take out the value that I passed
const imagePath = require('path-to-image');
当我在imagePath上记录该值时,我得到了值3。它是什么意思-它像资源id吗
然后,我将该imagePath传递给本机Java层,并使用它创建通知:
int resId = config.getNotificationIconPath(); // Here I take out the value that I passed
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle(config.getNotificationTitle())
.setContentText(config.getNotificationContent())
.setSmallIcon(resId)
.setContentIntent(mainActivityIntent)
.build();
startForeground(1, notification);
但是,当服务启动时,我在状态栏上看不到任何图标。
我想我的方法是错误的。
如何在react原生层中加载图像,然后在Java层中使用