我创建了一个bridge to React Native来使用Oracle-Responsys SDK。
桥工作得很好,但我唯一的问题是如何从我的react原生应用程序设置通知图标到这个桥。
遵循来自Responsys的documentations:
PushIOManager.getInstance(this).setDefaultSmallIcon(R.drawable.emo_im_surprised);
PushIOManager.getInstance(this).setDefaultLargeIcon(R.drawable.emo_im_happy);注意: Integer值必须是构建系统生成的资源ID。在上面的调用中,图标名称表示Integer值。例如,R.drawable.emo_im_surprised是已放置在可绘制文件夹中的图标emo_im_surprised.png的整数值。
我得到了这个,但这个R.drawable引用了我的桥的可绘制,而不是应用程序的可绘制,我如何在我的桥内使用我的应用程序中的图标?
发布于 2020-04-10 04:21:44
我创建这个函数解决了这个问题:
private int getDrawableId(String name) {
String packageName = getReactApplicationContext().getPackageName();
return getReactApplicationContext().getResources().getIdentifier(name, "drawable", packageName);
}并像这样使用它:
Integer notificationIcon = getDrawableId("ic_responsys_alt");
pushIOManager.setDefaultSmallIcon(notificationIcon);使用此代码,您只需在应用程序可绘制文件夹中添加一个名为ic_responsys_alt的图标。
https://stackoverflow.com/questions/61110158
复制相似问题