Cordova Android push icon on OneSignal

I’ve added OneSignal to an app for push notifications. They’re working well except the Android notifications don’t show our icon. I’ve followed their guide, but I can’t get it to work. Has anyone had luck with this?

Details on what I’ve tried:

I generated the icons and added them as below, and they show up in the cordova project on apparently the right path according to their guide. But the app stops receiving the notifications at all (whether triggered from their UI or by API). setExternalUserId returns successfully, other devices receive the same push just fine but the app does not receive anything. Only when I remove the icons do the push notifications work again (with the default icon).

I’ve checked the icon files are the right sizes and added them on these paths below:


And tried adding this to mobile-config.js (thanks @matheusccastro):

const dest = '/platforms/android/app/src/main/res';
const source = `cordova-build-override/${dest}`;
const small = 'ic_stat_onesignal_default.png';
const large = 'ic_onesignal_large_icon_default.png';

App.addResourceFile(`${source}/drawable-mdpi/${small}`, `${dest}/drawable-mdpi/${small}`, 'android');
App.addResourceFile(`${source}/drawable-hdpi/${small}`, `${dest}/drawable-hdpi/${small}`, 'android');
App.addResourceFile(`${source}/drawable-xhdpi/${small}`, `${dest}/drawable-xhdpi/${small}`, 'android');
App.addResourceFile(`${source}/drawable-xxhdpi/${small}`, `${dest}/drawable-xxhdpi/${small}`, 'android');
App.addResourceFile(`${source}/drawable-xxxhdpi/${small}`, `${dest}/drawable-xxxhdpi/${small}`, 'android');
App.addResourceFile(`${source}/drawable-xxxhdpi/${large}`, `${dest}/drawable-xxxhdpi/${large}`, 'android');

I’ve tried several variations of the path, always either push stops working or it ignores the icon. The paths above seem most correct, both going by their documentation and in that the files end up in folders with lots of other files with similar names, for example:

But as mentioned, notifications stop arriving. What am I missing?

PS: I didn’t add a values/strings.xml file as their documentation says. (When I do, the build process crashes, apparently due to another string file which they apparently already create on this path.) Instead, when I call their create notification API I add the property android_accent_color: 'FF5D31FF'. This works; when I remove the images, push arrives fine and the default icon gets this color.

@bartoftutormundi It seems that you are adding two times the hdpi, while you should add a large (256x256) and a normal (96x96) xxxhdpi image. Maybe this is the reason? It seems that if not all icons are set, the custom icon won’t appear.

One other thing that may be worth a try is to add those files using the App.addResourceFiles or even adding it on the config.xml as a resource-file. However, I think if you fix the icon naming it should work.

Thanks a lot @matheusccastro for the suggestions! I’ve changed everything you mentioned. Unfortunately the issue continues. I’ve updated the original post with what I’ve tried.

SOLVED - the push notifications not arriving doesn’t seem to be caused directly by the icon, but by the missing property channel_for_external_user_ids: "push" on the notifications API call. See Platform to deliver to. I still don’t get how exactly this is related to the push icon but it solves the problem ¯_(ツ)_/¯