How use notification icon from React Native app to some RNBridge?

293 views Asked by At

I created a bridge to React Native to work with Oracle-Responsys SDK.

The bridge is working pretty well, but the only thing that I'm stuck is in how can I set the notifications icons from my react native app to this bridge.

Following the documentations from Responsys:

PushIOManager.getInstance(this).setDefaultSmallIcon(R.drawable.emo_im_surprised);
PushIOManager.getInstance(this).setDefaultLargeIcon(R.drawable.emo_im_happy);

Notes: The Integer value must be a resource ID generated by the build system. In the calls above, the icon name represents the Integer value. For example, R.drawable.emo_im_surprised is the Integer value of the icon emo_im_surprised.png that has been placed in the drawable folder.

I got this, but this R.drawable references my bridge`s drawable not the app drawable, how can i use the icons from my app inside my bridge?

1

There are 1 answers

0
Diego Oliveira On

I solved this creating this function:

private  int getDrawableId(String name) {
        String packageName = getReactApplicationContext().getPackageName();
        return getReactApplicationContext().getResources().getIdentifier(name, "drawable", packageName);
}

and using it like this:

  Integer notificationIcon = getDrawableId("ic_responsys_alt");
  pushIOManager.setDefaultSmallIcon(notificationIcon);

with this code, you just need to add an icon called ic_responsys_alt inside app drawable folder.

that's the bridge we developed